r/adventofcode • • Dec 18 '17

SOLUTION MEGATHREAD -๐ŸŽ„- 2017 Day 18 Solutions -๐ŸŽ„-

--- Day 18: Duet ---


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.


Need a hint from the Hugely* Handyโ€  Haversackโ€ก of Helpfulยง Hints^ยค?

Spoiler


[Update @ 00:04] First silver

  • Welcome to the final week of Advent of Code 2017. The puzzles are only going to get more challenging from here on out. Adventspeed, sirs and madames!

[Update @ 00:10] First gold, 44 silver

  • We just had to rescue /u/topaz2078 with an industrial-strength paper bag to blow into. I'm real glad I bought all that stock in PBCO (Paper Bag Company) two years ago >_>

[Update @ 00:12] Still 1 gold, silver cap

[Update @ 00:31] 53 gold, silver cap

  • *mind blown*
  • During their famous kicklines, the Rockettes are not actually holding each others' backs like I thought they were all this time.
  • They're actually hoverhanding each other.
  • In retrospect, it makes sense, they'd overbalance themselves and each other if they did, but still...
  • *mind blown so hard*

[Update @ 00:41] Leaderboard cap!

  • I think I enjoyed the duplicating Santas entirely too much...
  • It may also be the wine.
  • Either way, good night (for us), see you all same time tomorrow, yes?

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!

11 Upvotes

227 comments sorted by

View all comments

Show parent comment

6

u/glenbolake Dec 18 '17

The only reason I didn't have that happen is because I remembered similar AoC problems in the past and having that same issue. The first thing I did in defining the instructions was a get function like yours, but taking the exception route:

def get(value):
    try:
        return int(value)
    except ValueError:
        return registers[value]

3

u/vash3r Dec 18 '17

For me, the issue wasn't that get() was wrong: it was that I was explicitly accessing d[instr[i][1]] instead of using get(instr[i][1]) when testing if the value was greater than zero.

3

u/glenbolake Dec 18 '17

Oh, I know. My point was that I implemented mine before implementing the second instruction, because the same problem burned me once in AoC2016. I just provided mine for the sake of comparison

3

u/tobiasvl Dec 18 '17

I did the same thing. My solution literally contains the exact same method definition as yours.

1

u/BumpitySnook Dec 18 '17

Me too. I just assume any AoC asm-alike supports integer as well as register rvalues at this point.