Keeping the old solution for the ranges was too ineffective when it
came to enumerating all contained integers, the amount of elements was
too large to either expand the ranges into Sets or similar.
However, it turned out (after some thinking) to be fairly
straight-forward to check if consecutive ranges overlapped, and in
that case merge them. The solution therefore now parses the ranges,
sorts them on the first component and then merges them as far as
possible.
changes: JJ: M app/Day5.hs
Part two is solved by repeatedly removing all free rolls until there
are no more rolls to remove. When removing the rolls we keep a running
count of how many rolls we've removed.
We look at each valid (having coordinates inside the grid) neighbor to
a cell including a paper roll and then see if the neighbor contains a
roll of paper or not. Finally we count the number of rolls, if it is
less than 4 we can pick it.
The solution I went with is to walk the entire bank of batteries with
their joltages and pair them up. At every step I can either form an
incomplete candidate (Left x), or a complete candidate (Right (a, b))
if I already have a previous candidate.