From 9629f5598527ad3744c857749e869467a35beae1 Mon Sep 17 00:00:00 2001 From: Siphalor Date: Sat, 14 Dec 2024 00:02:37 +0100 Subject: [PATCH] Day thirteen corrected --- day-13-haskell/src/Lib.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/day-13-haskell/src/Lib.hs b/day-13-haskell/src/Lib.hs index 1eeabcc..a8a5667 100644 --- a/day-13-haskell/src/Lib.hs +++ b/day-13-haskell/src/Lib.hs @@ -37,7 +37,6 @@ task1 input = do task2 :: String -> IO IntType task2 input = do - print $ zip machines (map tryCalculate machines) return $ sum bestPrices where bestPrices :: [IntType] @@ -63,7 +62,7 @@ tryCalculate Machine{ } = let a = -(pY % bY - pX % bX) / (aX % bX - aY % bY) an = numerator a in case denominator a of - 1 -> Just $ Vec2 an ((pX - an * aX) `div` bX) + 1 -> fmap (Vec2 an) ((pX - an * aX) `safeDiv` bX) _ -> Nothing safeDiv :: IntType -> IntType -> Maybe IntType