aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/03/solver.jl
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-01-28 03:46:12 +0100
committerOscar Najera <hi@oscarnajera.com>2023-01-28 03:46:12 +0100
commit84ec86b63ac38423ce021448e379b87094f7d4ac (patch)
tree6574d8b2b5aef30845f38e279a4c389d9fa8897e /AoC2022/03/solver.jl
parent497dc1ea9de502761c00ead6de62abe6eeea67d6 (diff)
downloadscratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.gz
scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.bz2
scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.zip
more julia and formatted
Diffstat (limited to 'AoC2022/03/solver.jl')
-rw-r--r--AoC2022/03/solver.jl7
1 files changed, 5 insertions, 2 deletions
diff --git a/AoC2022/03/solver.jl b/AoC2022/03/solver.jl
index 1ebadbf..13bb2a9 100644
--- a/AoC2022/03/solver.jl
+++ b/AoC2022/03/solver.jl
@@ -4,9 +4,12 @@ data = open("input") do f
split(read(f, String))
end
-priority(x) = islowercase(x) ? x - 'a' + 1 : x - 'A' +27
+priority(x) = islowercase(x) ? x - 'a' + 1 : x - 'A' + 27
@testset "solutions" begin
- @test map(s-> intersect(s[1:length(s)÷2], s[length(s)÷2+1:end])[1] |> priority, data) |> sum == 8072
+ @test map(
+ s -> intersect(s[1:length(s)÷2], s[length(s)÷2+1:end])[1] |> priority,
+ data,
+ ) |> sum == 8072
@test [intersect(data[i:i+2]...)[1] for i ∈ 1:3:length(data)] .|> priority |> sum == 2567
end