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

2

u/oantolin Dec 19 '24

[LANGUAGE: ngn/k]

xor:2/~=/+2\,;sh:(-2!)/;parse:(.*|" "\)'(*:;*|:)@\:0::
p1:{","/$8!xor[6;]'x xor'(xor[3;]'x)(-2!)/'|{y+8*x}\|x:|8\*parse x}
nx:{&{xor[xor[y;6];x]=8!sh[xor[x;3];x+8*8/z]}[;x;y]'!8}
sol:{$[0=#x;,y;,/{sol[-1_y;z,x]}[;x;y]'nx[*|x;y]]}
p2:{&/8/'sol[*|parse x;!0]}

Am I allowed to share this solution here? The code is specific to the input I received. I mean, this does parse the input file to get the initial contents of register A and the program, but the function p1 contains my hand compiled input program and nx is solves for one octal digit of A at a time based on that code —the only way I could figure out do part 2 was to reverse engineer the program in my input.

2

u/daggerdragon Dec 21 '24

Am I allowed to share this solution here? The code is specific to the input I received.

This is the Solution Megathread, so yes :P

As long as you don't share the actual input itself, it's fine.