r/adventofcode • u/daggerdragon • Dec 08 '23
SOLUTION MEGATHREAD -❄️- 2023 Day 8 Solutions -❄️-
THE USUAL REMINDERS
- All of our rules, FAQs, resources, etc. are in our community wiki.
Outstanding moderator challenges:
Community fun event 2023: ALLEZ CUISINE!
- Submissions megathread is now unlocked!
- 14 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!
AoC Community Fun 2023: ALLEZ CUISINE!
Today's theme ingredient is… *whips off cloth covering and gestures grandly*
International Ingredients
A little je ne sais quoi keeps the mystery alive. Try something new and delight us with it!
Code in a foreign language
- Written or programming, up to you!
- If you don’t know any, Swedish Chef or even pig latin will do
- Test your language’s support for Unicode and/or emojis
Visualizationsusing Unicode and/or emojis are always lovely to see
ALLEZ CUISINE!
Request from the mods: When you include a dish entry alongside your solution, please label it with [Allez Cuisine!] so we can find it easily!
--- Day 8: Haunted Wasteland ---
Post your code solution in this megathread.
- Read the full posting rules in our community wiki before you post!
- State which language(s) your solution uses with
[LANGUAGE: xyz] - Format code blocks using the four-spaces Markdown syntax!
- Quick link to Topaz's
pasteif you need it for longer code blocks
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:10:16, megathread unlocked!
52
Upvotes
View all comments
Show parent comment
1
u/morgoth1145 Dec 08 '23
Hm, thinking about it I think I actually have something coded up in my lib.math module which would apply here. Take a look at
chinese_remainder_incongruenceoroffset_chinese_remainder_incongruence(which delegates to the former but accepts a slightly different set of expressions that make more sense in my head.) Obviously converting the cycles to all the incongruencies is absurd, but the first step in my algorithm is converting to candidate valid congruencies which does match this problem well.If I remember correctly what I was doing was kind of an extended CRT where I deal with the cartesian product of two mod bases at a time and merging them, trusting that most of the options would be eliminated at each iteration keeping the overall working set small.
That said, I am not going to try to fit this general problem to that algorithm tonight, it's already nearly 1AM and I need sleep :)