Advent of Code 2024 - Day 8

@ken-kost your part 1 was faster for me. I’m not using aoc though so that might have something to do with it?

I ran:

Benchee.run(%{
  "part1" => fn ->
    "inputs/day08/input2.txt"
    |> Aoc2024.Solutions.Y24.Day08.parse(1)
    |> Aoc2024.Solutions.Y24.Day08.part_one()
  end,
  "part2" => fn ->
    "inputs/day08/input2.txt"
    |> Aoc2024.Solutions.Y24.Day08.parse(2)
    |> Aoc2024.Solutions.Y24.Day08.part_two()
  end
})

After replacing the Aoc.Input part with:

# Before
stream = Input.stream!(input, trim: true)

# After
stream =
  input
  |> File.stream!()
  |> Stream.map(&String.trim/1)
  |> Stream.reject(&(&1 == ""))

and I got:

Name            ips        average  deviation         median         99th %
part1        1.25 K        0.80 ms    ±39.13%        0.75 ms        1.43 ms
part2        0.99 K        1.01 ms    ±19.68%        0.95 ms        1.70 ms
1 Like