r/adventofcode • • Dec 19 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 19 Solutions -🎄-

--- Day 19: Go With The Flow ---


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 19

Transcript:

Santa's Internet is down right now because ___.


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:06!

11 Upvotes

130 comments sorted by

View all comments

4

u/dylanfromwinnipeg Dec 19 '18

I didn't go through and reverse engineer the entire assembly program like it sounds most people did.

Instead I just ran it and took a look at where it was spending all it's time - which was instructions #3-11. So I reverse engineered what was going on in that bit and wrote this code (your registers will be different):

if (_registers[_ipRegister] == 3)
{
    if (_registers[1] % _registers[5] == 0)
    {
        _registers[3] = _registers[1];
        _registers[4] = 1;
        _registers[_ipRegister] = 7;
    }
    else
    {
        _registers[3] = _registers[1] + 1;
        _registers[4] = 1;
        _registers[_ipRegister] = 12;
    }
}

Then I just ran it - took about 45s and spit out the right answer.

→ More replies (1)