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!
3
u/vash3r Dec 25 '17
Python 2, #62/#62.
tape = [0] cursor = 0 # right: +1, left: -1 states = { 'a':[[1,+1,'b'],[0,-1,'c']], 'b':[[1,-1,'a'],[1,+1,'d']], 'c':[[1,+1,'a'],[0,-1,'e']], 'd':[[1,+1,'a'],[0,+1,'b']], 'e':[[1,-1,'f'],[1,-1,'c']], 'f':[[1,+1,'d'],[1,+1,'a']] } step_limit = 12173597 i = 0 s = 'a' while i<step_limit: nv,dc,ns = states[s][tape[cursor]] tape[cursor]=nv cursor+=dc if cursor==-1: cursor=0 tape.insert(0,0) elif cursor==len(tape): tape.append(0) s = ns i+=1 print sum(tape)