tried to solve this one using only incrementing sums, which worked fine for the test input but not the actual puzzle input. By a complete rewrite to actually render the tree as a map, it worked. The spontanious data store is a mess and cost me much time to work around, since I wanted to have a list of tuples with all the sizes for each directory. Took 2 days to figure this one out. Not proud.
47 lines
629 B
Elixir
47 lines
629 B
Elixir
defmodule Day07Test do
|
|
use ExUnit.Case
|
|
doctest Aoc.Solution.Day07
|
|
import Aoc.Solution.Day07
|
|
|
|
@input ~s(
|
|
$ cd /
|
|
$ ls
|
|
dir a
|
|
14848514 b.txt
|
|
8504156 c.dat
|
|
dir d
|
|
$ cd a
|
|
$ ls
|
|
dir e
|
|
29116 f
|
|
2557 g
|
|
62596 h.lst
|
|
$ cd e
|
|
$ ls
|
|
584 i
|
|
$ cd ..
|
|
$ cd ..
|
|
$ cd d
|
|
$ ls
|
|
4060174 j
|
|
8033020 d.log
|
|
5626152 d.ext
|
|
7214296 k
|
|
)
|
|
|
|
test "07: No Space Left On Device, part 1" do
|
|
expected = 95437
|
|
|
|
result = @input |> parse!() |> solve()
|
|
|
|
assert result == expected
|
|
end
|
|
|
|
test "07: No Space Left On Device, part 2" do
|
|
expected = 24_933_642
|
|
|
|
result = @input |> parse!() |> solve_again()
|
|
|
|
assert result == expected
|
|
end
|
|
end
|