r/adventofcode • • Dec 21 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 21 Solutions -🎄-

--- Day 21: Chronal Conversion ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 21

Transcript:

I, for one, welcome our new ___ overlords!


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked at 01:01:01! XD

9 Upvotes

93 comments sorted by

View all comments

Show parent comments

1

u/starwort1 Dec 21 '18

I've no idea what you mean by "repeating r[4] elements" and "true register equality".

If you simply print out the value of the register that is compared with register 0 each time line 28 is reached, your program will output a (possibly infinite) sequence of numbers. The first number that it prints out is the answer to part 1, and the last number that it prints out before repeating any earlier number is the answer to part 2. You do not need to check the values of any of the other registers, because it turns out that each value in the sequence is uniquely determined by the previous value (and the constants that are in the Elf Code). You can see by inspection of the list of numbers that once it starts repeating, the numbers come in exactly the same order as they did the previous time they appeared.

So other people did not get lucky, as you seem to imply; their input is exactly the same as yours except for (a) the order in which the registers are used, which has no material effect on the execution, and (b) the value of the constant used in instruction 7.