tiny simplification - more later
This commit is contained in:
parent
c5b88598d8
commit
88a64017fc
1 changed files with 5 additions and 8 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue