From b9ca1480961a8db517fee0ec5c5f7497fed0f905 Mon Sep 17 00:00:00 2001 From: Adam Millerchip Date: Tue, 10 Dec 2024 17:40:41 +0900 Subject: [PATCH] Remove unneeded max_x when parsing input --- 2024/day10.exs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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