fix top_crates function that assumed ordered map

main
Adam Millerchip 4 months ago
parent a6911216fa
commit 58df8b822b

@ -19,7 +19,9 @@ defmodule Day5 do
end
defp top_crates(stacks) do
Enum.reduce(stacks, "", fn {_label, [top | _stack]}, acc -> acc <> top end)
stacks
|> Enum.sort_by(fn {label, _stack} -> label end)
|> Enum.reduce("", fn {_label, [top | _stack]}, acc -> acc <> top end)
end
def input do

Loading…
Cancel
Save