From 92bbd022a44a7c80b011b3c9df64a36ff0dfbbfe Mon Sep 17 00:00:00 2001 From: Javran Cheng Date: Sun, 7 Jan 2024 22:59:28 -0800 Subject: [PATCH] day 5 done (for now) so the dumb method of actually trying everything works. example is fast enough, let's call it here. need to go back later to optimize a bit for sure. --- README.md | 2 +- data/testdata/2023/day/5/example.expect.txt | 2 ++ src/Javran/AdventOfCode/Y2023/Day5.hs | 4 +++- test/Javran/AdventOfCode/TestdataSpec.hs | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 data/testdata/2023/day/5/example.expect.txt diff --git a/README.md b/README.md index 454d1ecc..f3b1da0e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Solutions, scripting, and templates - all in one repo. | `<++++++++>` | `<++++++++>` | `<++++++++>` | `<++++++++>` | `<++++++++>` | | :-: | :-: | :-: | :-: | :-: | -| ☑ [Day 1](src/Javran/AdventOfCode/Y2023/Day1.hs) | ☑ [Day 2](src/Javran/AdventOfCode/Y2023/Day2.hs) | ☑ [Day 3](src/Javran/AdventOfCode/Y2023/Day3.hs) | ☑ [Day 4](src/Javran/AdventOfCode/Y2023/Day4.hs) | ☐ [Day 5](src/Javran/AdventOfCode/Y2023/Day5.hs) | +| ☑ [Day 1](src/Javran/AdventOfCode/Y2023/Day1.hs) | ☑ [Day 2](src/Javran/AdventOfCode/Y2023/Day2.hs) | ☑ [Day 3](src/Javran/AdventOfCode/Y2023/Day3.hs) | ☑ [Day 4](src/Javran/AdventOfCode/Y2023/Day4.hs) | ☑ [Day 5](src/Javran/AdventOfCode/Y2023/Day5.hs) | ### 2022 diff --git a/data/testdata/2023/day/5/example.expect.txt b/data/testdata/2023/day/5/example.expect.txt new file mode 100644 index 00000000..38f67181 --- /dev/null +++ b/data/testdata/2023/day/5/example.expect.txt @@ -0,0 +1,2 @@ +35 +46 diff --git a/src/Javran/AdventOfCode/Y2023/Day5.hs b/src/Javran/AdventOfCode/Y2023/Day5.hs index 1447af6f..c057aee5 100644 --- a/src/Javran/AdventOfCode/Y2023/Day5.hs +++ b/src/Javran/AdventOfCode/Y2023/Day5.hs @@ -65,8 +65,10 @@ mkMapper xs = auxLookup where (lm, cur, _) = IM.splitLookup i m +-- TODO: may want to go back and figure out how to do this faster. +-- TODO: I feel IntMap might have added too much overhead to our liking. need to try a linear version. instance Solution Day5 where - solutionSolved _ = False + solutionSolved _ = True solutionRun _ SolutionContext {getInputS, answerShow} = do (seeds, maps) <- consumeOrDie almanacP <$> getInputS let ff = foldl' (\r m -> mkMapper m . r) id maps diff --git a/test/Javran/AdventOfCode/TestdataSpec.hs b/test/Javran/AdventOfCode/TestdataSpec.hs index 53cc7f67..dfed2ab5 100644 --- a/test/Javran/AdventOfCode/TestdataSpec.hs +++ b/test/Javran/AdventOfCode/TestdataSpec.hs @@ -34,7 +34,7 @@ import Test.Hspec {- ORMOLU_DISABLE -} hashForForceRecompliation :: String -- FORCE_RECOMP_HASH_BEGIN -hashForForceRecompliation = "2b2c8dbe74b31620893f146faed64d3437cbc12a85d5ce6c2945fbd8f6968d66" +hashForForceRecompliation = "c26accacf60e31f3d7254bdd3c0d265bedebf5c6ac8c4b06c25857b3576dda07" -- FORCE_RECOMP_HASH_END {- ORMOLU_ENABLE -}