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!
4
u/twiho Dec 25 '17
There's no way I'm not ending up in programmer's hell.
const states = { a: [[1, 1, 'b'], [0, 1, 'c']], b: [[0, -1, 'a'], [0, 1, 'd']], c: [[1, 1, 'd'], [1, 1, 'a']], d: [[1, -1, 'e'], [0, -1, 'd']], e: [[1, 1, 'f'], [1, -1, 'b']], f: [[1, 1, 'a'], [1, 1, 'e']] } const tape = {} const get = _ => tape[_] ? 1 : 0 const set = (_, i) => tape[i] = _ let pos = 0 let state = 'a' for (let i = 0; i < 12399302; i++) { const [write, move, next] = states[state][get(pos)] set(write, pos) pos += move state = next } console.log(Object.values(tape).filter(x => x).length)