From deae1f300f0231aabf9ac5df6a08f28408e4582b Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Mon, 9 Dec 2024 21:31:22 -0800 Subject: [PATCH] cleanup --- solutions/src/2024/10.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/solutions/src/2024/10.hs b/solutions/src/2024/10.hs index 37a3c58..1688992 100644 --- a/solutions/src/2024/10.hs +++ b/solutions/src/2024/10.hs @@ -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]