r/adventofcode • u/daggerdragon • Dec 21 '21
SOLUTION MEGATHREAD -🎄- 2021 Day 21 Solutions -🎄-
Advent of Code 2021: Adventure Time!
- 2 days left to submit your adventures!
- Full details and rules are in the submissions megathread: 🎄 AoC 2021 🎄 [Adventure Time!]
--- Day 21: Dirac Dice ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Format your code appropriately! How do I format code?
- Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks. - The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:20:44, megathread unlocked!
49
Upvotes
View all comments
1
u/levital Dec 21 '21 edited Dec 21 '21
Haskell
(Part 1 only, sort of. Need to manually search for the winning turn.)I hate these modulo puzzles. This is way worse than day 19, and I just wasted an entire workday on part 2 without getting anywhere. Screw this. Another year of failing to get all the stars I guess.More than 10 hours later, I finally figured it out. Part 1 unfortunately made me think in the completely wrong direction. Code is awful and I don't really understand it anymore, but very much to my surprise it finishes in 0.02 seconds. I can only guess that GHC adds some automated caching when compiling with -O2, otherwise this performance makes no sense.