How many units of sand come to rest before sand starts flowing into the abyss below?
- split by newline
- reduce to
MapSet
of rocks, viafor
comprehensions Enum.chunk_every/4
comes in very handy
- first, compute the max depth; anything beyond is
:infinity
- use the iterative function is
drop_sand/3
which increments a unit counter each time it is called - call itself until the next sand unit falls off (returns
:infinity
)
mix run
mix test