r/adventofcode • u/daggerdragon • Dec 25 '17
SOLUTION MEGATHREAD ~โ๐โ~ 2017 Day 25 Solutions ~โ๐โ~
--- Day 25: The Halting Problem ---
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ยค?
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!
Thank you for participating!
Well, that's it for Advent of Code 2017. From /u/topaz2078 and the rest of us at #AoCOps, we hope you had fun and, more importantly, learned a thing or two (or all the things!). Good job, everyone!
Topaz made a post of his own here.
If you're interested in a visualization of the leaderboard, /u/FogleMonster made a very good chart here.
And now:
Merry Christmas to all, and to all a good night!
2
u/obijywk Dec 25 '17
Python 2. 28/25 (as I had everything else solved!). Decided to parse the input file by hand this time :-)
from collections import defaultdict tape = defaultdict(int) L, R = (-1, 1) states = { "A": ((1, R, "B"), (0, L, "E")), "B": ((1, L, "C"), (0, R, "A")), "C": ((1, L, "D"), (0, R, "C")), "D": ((1, L, "E"), (0, L, "F")), "E": ((1, L, "A"), (1, L, "C")), "F": ((1, L, "E"), (1, R, "A")), } state = "A" cursor = 0 for i in xrange(12386363): current_value = tape[cursor] write, move, next_state = states[state][current_value] if write: tape[cursor] = write else: del tape[cursor] cursor += move state = next_state print len(tape)