diff --git a/2024/day10.exs b/2024/day10.exs index 9733ce7..9445503 100644 --- a/2024/day10.exs +++ b/2024/day10.exs @@ -2,15 +2,15 @@ defmodule Day10 do def part1({grid, zeros}) do zeros - |> Enum.map(fn point -> point |> score(grid, 0) |> Enum.uniq() |> Enum.count() end) + |> Enum.map(fn point -> point |> find_trails(grid, 0) |> Enum.uniq() |> Enum.count() end) |> Enum.sum() end - def score(point, _grid, 9), do: [point] + def find_trails(point, _grid, 9), do: [point] - def score({x, y}, grid, height) do + def find_trails({x, y}, grid, height) do find_neighbours(x, y, height, grid) - |> Enum.flat_map(fn {point, _} -> score(point, grid, height + 1) end) + |> Enum.flat_map(fn {point, _} -> find_trails(point, grid, height + 1) end) end def find_neighbours(x, y, height, grid) do @@ -23,7 +23,7 @@ defmodule Day10 do def part2({grid, zeros}) do zeros - |> Enum.map(fn point -> point |> score(grid, 0) |> Enum.count() end) + |> Enum.map(fn point -> point |> find_trails(grid, 0) |> Enum.count() end) |> Enum.sum() end