Copyright | (c) Eric Mertens 2023 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
https://adventofcode.com/2023/day/16
This is a pretty straight forward graph traversal of the state space. I represent nodes of the "graph" being searched as pairs of a location and a direction vector. At each step the location is used to look up the tile and the direction vector is used to compute reflections and splits.
Optimizations:
- Parallelize the search in part 2
- Only track seen states for beam splitters
- Count visited locations with an array instead of a Set
- Pack photon states into an Int to make seen set lookups faster
>>>
:{
:main + ".|...\\.... |.-.\\..... .....|-... ........|. .......... .........\\ ..../.\\\\.. .-.-/..|.. .|....-|.\\ ..//.|.... " :} 46 51