sln_2023_16
Copyright(c) Eric Mertens 2023
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

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
Synopsis

Documentation

main :: IO () Source #

Parse the input grid and print answers to both parts.

>>> :main
7979
8437