From 02ee5cb935552f40181c481b02f8c286dd93029b Mon Sep 17 00:00:00 2001 From: pingu Date: Mon, 1 Dec 2025 08:58:46 +0100 Subject: [PATCH] After cheating a bit... --- app/1.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/1.hs b/app/1.hs index e6a3efd..f4f5b75 100644 --- a/app/1.hs +++ b/app/1.hs @@ -20,20 +20,23 @@ solver b = go 50 go _ [] = 0 go curr (RRight n : xs) = let (rots,newCurr) = bound (curr + n) in - (if | b -> (rots+) + (if | b -> (rots +) | newCurr == 0 -> (1+) - | otherwise -> id) $ go newCurr xs + | otherwise -> id) $ + go newCurr xs go curr (RLeft n : xs) = let (rots,newCurr) = bound (curr - n) in - (if | b -> (rots+) + (if | b -> (rots - (if curr == 0 then 1 else 0) +) | newCurr == 0 -> (1+) - | otherwise -> id) $ go newCurr xs + | otherwise -> id) $ + go newCurr xs bound :: Int -> (Int,Int) bound x - | x < 0 = (\(n,y) -> (n+1,y)) . bound $ x + 100 - | x > 99 = (\(n,y) -> (n+1,y)) . bound $ x - 100 - | otherwise = (0, x) + | x < 0 = (\(n,y) -> (n+1,y)) . bound $ x + 100 + | x == 0 || x == 100 = (1,0) + | x > 99 = (\(n,y) -> (n+1,y)) . bound $ x - 100 + | otherwise = (0, x) main :: IO () main = readFile "inputs/1" <&> parse >>= \i ->