aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/03/solver.jl
blob: 1ebadbfe2f791c6a097e33eda2f6f2ae3a411ab7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
using Test

data = open("input") do f
    split(read(f, String))
end

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 [intersect(data[i:i+2]...)[1] for i  1:3:length(data)] .|> priority |> sum == 2567
end