Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 10, 2024
1 parent bd93890 commit deae1f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions solutions/src/2024/10.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ main =
print (part2 input)

part1 :: UArray Coord Char -> Int
part1 a = length [() | (start, '0') <- assocs a, i <- dfs step start, a ! i == '9']
part1 a = length [() | (start, '0') <- assocs a, end <- dfs step start, a!end == '9']
where
step x = [y | y <- cardinal x, Just (succ (a ! x)) == arrIx a y ]
step x = [y | y <- cardinal x, h <- arrIx a y, succ (a ! x) == h]

part2 :: UArray Coord Char -> Int
part2 a = length [() | (start, '0') <- assocs a, (i, _) <- dfs step (start, []), a ! i == '9']
part2 a = length [() | (start, '0') <- assocs a, (end, _) <- dfs step (start, []), a!end == '9']
where
step (x, xs) = [(y, x : xs) | y <- cardinal x, Just (succ (a ! x)) == arrIx a y]
step (x, xs) = [(y, x:xs) | y <- cardinal x, h <- arrIx a y, succ (a!x) == h]

0 comments on commit deae1f3

Please sign in to comment.