Expand description
ยงThe Floor Will Be Lava
Brute force solution tracing the path of each beam, changing direction or splitting according to the rules of each tile.
To speed things up the next coordinate in each direction is precomputed for every point so that the empty spaces between mirrros and splitters are filled efficiently.
Some beams can enter a closed loop so we keep track of previously seen (position, direction)
pairs and stop if weโve seen a pair before.
For part two each path is independent so we can use multiple threads in parallel to speed up the search.
Structsยง
- Shared ๐Atomics can be safely shared between threads.
Constantsยง
Functionsยง
- count ๐Count the number of energized tiles from a single starting location.
- Build four precomputed grids of the next coordinate in each direction for every point.
- worker ๐Process starting locations from a shared queue.
Type Aliasesยง
- Pair ๐