diff --git a/2024/day10.exs b/2024/day10.exs index 9445503..94e65a8 100644 --- a/2024/day10.exs +++ b/2024/day10.exs @@ -30,13 +30,13 @@ defmodule Day10 do def input do with [input_filename] <- System.argv(), {:ok, input} <- File.read(input_filename) do - {grid, zeros, _, _, _} = - for <>, reduce: {%{}, [], 0, 0, 0} do - {grid, zeros, x, max_x, y} -> + {grid, zeros, _, _} = + for <>, reduce: {%{}, [], 0, 0} do + {grid, zeros, x, y} -> case char do - "\n" -> {grid, zeros, 0, x, y + 1} - "0" -> {Map.put(grid, {x, y}, 0), [{x, y} | zeros], x + 1, max_x, y} - char -> {Map.put(grid, {x, y}, String.to_integer(char)), zeros, x + 1, max_x, y} + "\n" -> {grid, zeros, 0, y + 1} + "0" -> {Map.put(grid, {x, y}, 0), [{x, y} | zeros], x + 1, y} + char -> {Map.put(grid, {x, y}, String.to_integer(char)), zeros, x + 1, y} end end