From 4d74260d8a204f1a09b01d4177a21e0d4cbff28e Mon Sep 17 00:00:00 2001 From: Adam Millerchip Date: Tue, 10 Dec 2024 17:16:54 +0900 Subject: [PATCH] s/score/find_trails/g --- 2024/day10.exs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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