puzzle.jl 413 B

1234567891011121314
  1. using BenchmarkTools
  2. inputfile = joinpath(@__DIR__, "input.txt")
  3. input =
  4. readlines(inputfile) .|>
  5. x -> split(x, ',') .|> x -> replace(x, '-' => ':') .|> x -> Meta.parse.(x) .|> eval
  6. answer1 =
  7. (input .|> x -> (issubset(x...), issubset(reverse(x)...)) |> x -> x[1] || x[2]) |> sum
  8. answer2 = (input .|> x -> intersect(x...) |> length) |> x -> findall(!iszero, x) |> length
  9. print((answer1, answer2))