Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 17, 2023
1 parent 990a801 commit 09c23b9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions solutions/src/2023/17.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Maintainer : emertens@gmail.com
<https://adventofcode.com/2023/day/17>
Shortest-path graph search where the graph states are the triple of
a location, direction, and distance traveled in that direction.
>>> :{
:main +
"2413432311323
Expand All @@ -24,7 +27,7 @@ Maintainer : emertens@gmail.com
1224686865563
2546548887735
4322674655533
"
"
:}
102
94
Expand Down Expand Up @@ -77,12 +80,12 @@ data S = S !Coord !Coord !Int -- ^ location, direction, distance
step :: Int -> Int -> UArray Coord Int -> S -> [AStep S]
step lo hi input (S here dir dist) =
[ AStep {
astepNext = S next dir' dist',
astepNext = S here' dir' dist',
astepCost = cost,
astepHeuristic = 0}
| (dir', dist') <-
[(dir, dist + 1) | dist < hi] ++
if dist < lo then [] else [(turnLeft dir, 1), (turnRight dir, 1)]
, let next = here + dir'
, cost <- arrIx input next
, let here' = here + dir'
, cost <- arrIx input here'
]

0 comments on commit 09c23b9

Please sign in to comment.