From b0f15c1c678a28702203eb1667f8a56924ef6e52 Mon Sep 17 00:00:00 2001 From: Alexandre Jesus Date: Tue, 10 Dec 2024 00:01:10 +0000 Subject: Day 9, improve me comment --- src/day09.exs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/day09.exs') 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) -- cgit v1.2.3