Copyright | (c) Eric Mertens 2021 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
https://adventofcode.com/2021/day/22
This solution processes commands in order and tracks the currently lit regions with a list of disjoint cubes. When processing a new cube, the cube is deleted from the list of lit cubes and then added back in as a whole cube if the command would turn lights on.
A slower, but also popular solution using the Inclusion-Exclusion Principle
can be found in solveInEx
.
https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle