From a70fbe88b8fb9f7031f08baff03837ee5c78f1f8 Mon Sep 17 00:00:00 2001 From: Javran Cheng Date: Sun, 7 Jan 2024 22:42:19 -0800 Subject: [PATCH] too lazy to think give it a few hours see if we can just bruteforce this, since there's no really memory pressure that we can run this as long as we want. --- src/Javran/AdventOfCode/Y2023/Day5.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Javran/AdventOfCode/Y2023/Day5.hs b/src/Javran/AdventOfCode/Y2023/Day5.hs index 83d559b8..1447af6f 100644 --- a/src/Javran/AdventOfCode/Y2023/Day5.hs +++ b/src/Javran/AdventOfCode/Y2023/Day5.hs @@ -69,6 +69,8 @@ instance Solution Day5 where solutionSolved _ = False solutionRun _ SolutionContext {getInputS, answerShow} = do (seeds, maps) <- consumeOrDie almanacP <$> getInputS - let fs = fmap mkMapper maps - locs = foldl' (\xs f -> fmap f xs) seeds fs - answerShow (minimum locs) + let ff = foldl' (\r m -> mkMapper m . r) id maps + answerShow (minimum $ fmap ff seeds) + answerShow $ minimum do + [l, rng] <- chunksOf 2 seeds + fmap ff [l .. l + rng-1]