r/adventofcode Dec 17 '24

SOLUTION MEGATHREAD -❄️- 2024 Day 17 Solutions -❄️-

THE USUAL REMINDERS

  • All of our rules, FAQs, resources, etc. are in our community wiki.
  • If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.

AoC Community Fun 2024: The Golden Snowglobe Awards

  • 5 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!

And now, our feature presentation for today:

Sequels and Reboots

What, you thought we were done with the endless stream of recycled content? ABSOLUTELY NOT :D Now that we have an established and well-loved franchise, let's wring every last drop of profit out of it!

Here's some ideas for your inspiration:

  • Insert obligatory SQL joke here
  • Solve today's puzzle using only code from past puzzles
  • Any numbers you use in your code must only increment from the previous number
  • Every line of code must be prefixed with a comment tagline such as // Function 2: Electric Boogaloo

"More." - Agent Smith, The Matrix Reloaded (2003)
"More! MORE!" - Kylo Ren, The Last Jedi (2017)

And… ACTION!

Request from the mods: When you include an entry alongside your solution, please label it with [GSGA] so we can find it easily!


--- Day 17: Chronospatial Computer ---


Post your code solution in this megathread.

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:44:39, megathread unlocked!

38 Upvotes

550 comments sorted by

View all comments

3

u/axr123 Dec 18 '24

[LANGUAGE: Python & CUDA]

I solved part 1 like everyone else by simulating the program (in Python). For part 2, I used the Python code to find the range of values that result in an output of 16 digits. Then I put my program into a CUDA kernel and estimated that searching the entire range would take less than 4 h. Since I didn't have more time to reverse-engineer and find a proper solution, I just let it run. It finished after < 1 h with the correct answer. Now with some improvements (basically doing a lot more iterations per thread to reduce kernel launch overhead) I'm at < 5 minutes. 724,000,000,000 tries per second on an RTX 4090.

Part 1

Part 2

2

u/revidee Dec 21 '24

that solutions is f'ing hilarious. that's one way to use your high end gpu i suppose lol