fix top_crates function that assumed ordered map
This commit is contained in:
parent
a6911216fa
commit
58df8b822b
1 changed files with 3 additions and 1 deletions
|
@ -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…
Reference in a new issue