s/score/find_trails/g
This commit is contained in:
parent
4879d7a7d2
commit
4d74260d8a
1 changed files with 5 additions and 5 deletions
|
@ -2,15 +2,15 @@
|
||||||
defmodule Day10 do
|
defmodule Day10 do
|
||||||
def part1({grid, zeros}) do
|
def part1({grid, zeros}) do
|
||||||
zeros
|
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()
|
|> Enum.sum()
|
||||||
end
|
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)
|
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
|
end
|
||||||
|
|
||||||
def find_neighbours(x, y, height, grid) do
|
def find_neighbours(x, y, height, grid) do
|
||||||
|
@ -23,7 +23,7 @@ defmodule Day10 do
|
||||||
|
|
||||||
def part2({grid, zeros}) do
|
def part2({grid, zeros}) do
|
||||||
zeros
|
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()
|
|> Enum.sum()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue