summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Jesus <adbjesus@gmail.com>2024-12-10 00:01:10 +0000
committerAlexandre Jesus <adbjesus@gmail.com>2024-12-10 00:01:10 +0000
commitb0f15c1c678a28702203eb1667f8a56924ef6e52 (patch)
treeaf3c21c3da88a0c2a15c8d87e02a142dac73f8dc
parent2d8c5412171605bd0b7fedca407a087827cd1082 (diff)
downloadaoc2024-b0f15c1c678a28702203eb1667f8a56924ef6e52.tar.gz
aoc2024-b0f15c1c678a28702203eb1667f8a56924ef6e52.zip
Day 9, improve me comment
-rw-r--r--src/day09.exs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/day09.exs b/src/day09.exs
index 1e37cad..b8164e4 100644
--- a/src/day09.exs
+++ b/src/day09.exs
@@ -57,6 +57,11 @@ defmodule Day09 do
defp locations(acc \\ [], revfiles, spaces)
+ # a (block size), b (block position), i (block index)
+ # c (space size), d (space position)
+ # IMPROVE ME: since there are at most 9 sizes, we could keep the
+ # locations of the spaces in a tree for each size, and achieve
+ # better performance, might do it later..
defp locations(acc, [{{a, b}, i} | t], spaces) do
spaces = Enum.filter(spaces, fn {_, d} -> d < b end)