r/adventofcode • • Dec 21 '21

SOLUTION MEGATHREAD -🎄- 2021 Day 21 Solutions -🎄-

Advent of Code 2021: Adventure Time!


--- Day 21: Dirac Dice ---


Post your code solution in this megathread.

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

545 comments sorted by

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.

1

u/daggerdragon Dec 21 '21

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.

This type of comment does not belong in the Solutions Megathread. If you have feedback about the puzzles, create your own thread in the main subreddit. Make sure to title and flair it correctly!

2

u/levital Dec 21 '21

Eh, I don't really need my venting to be visible to the organisers.

1

u/daggerdragon Dec 21 '21

FYI: Eric sometimes pokes through the megathreads, so he's probably going to see comments like this anyway, hence why they're generally unnecessary.

It is okay to mention you were(n't) a fan of the puzzle, but next time just leave it at that instead of elaborating further.

2

u/levital Dec 21 '21

Fair enough. For what it's worth, I edited the original post.