sln_2018_22
Copyright(c) Eric Mertens 2018
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2018/day/22

This solution uses an A* graph search to find the shortest path through the cave to the target.

I picked an arbitrary cave size to memoize that was big enough to avoid indexing errors. I use a boxed array so that I can lazily compute the geologic indexes of the various locations in the cave. This also allows me to recursively define geologic and erosion.

My A* heuristic is manhattan distance to the target plus a penalty for not holding the torch. (Accounting for the torch saves a small, but positive amount of time.)

Instead of modelling the tool being held directly I simply keep track of the risk number of the area I'm not allowed to enter.

Synopsis

Documentation

main :: IO () Source #

Print the answers to day 22