tiny simplification - more later

This commit is contained in:
Adam Millerchip 2022-12-07 22:48:19 +09:00
parent c5b88598d8
commit 88a64017fc

View file

@ -68,14 +68,11 @@ defmodule Day7 do
unused_space = @total_size - space_used unused_space = @total_size - space_used
space_to_free = @space_needed - unused_space space_to_free = @space_needed - unused_space
{_dir, size} =
store store
|> Enum.filter(&match?({_path, {:dir, _size, _paths}}, &1)) |> Enum.filter(&match?({_path, {:dir, _size, _paths}}, &1))
|> Enum.map(fn {[name | _], {:dir, size, _paths}} -> {name, size} end) |> Enum.map(fn {_path, {:dir, size, _paths}} -> size end)
|> Enum.sort_by(fn {_name, size} -> size end) |> Enum.sort()
|> Enum.find(fn {_name, size} -> size >= space_to_free end) |> Enum.find(fn size -> size >= space_to_free end)
size
end end
def input do def input do