Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Solution Day 25: The Halting Problem
#aoc_d25.py
tape = {}
state = 'A'
pos = 0
for i in range(12794428): #12794428
if pos not in tape:
tape[pos] = 0
if state == 'A':
if tape[pos] == 0:
tape[pos] = 1
pos+=1
state = 'B'
elif tape[pos] == 1:
tape[pos] = 0
pos-=1
state = 'F'
elif state == 'B':
if tape[pos] == 0:
tape[pos] = 0
pos+=1
state = 'C'
elif tape[pos] == 1:
tape[pos] = 0
pos+=1
state = 'D'
elif state == 'C':
if tape[pos] == 0:
tape[pos] = 1
pos-=1
state = 'D'
elif tape[pos] == 1:
tape[pos] = 1
pos+=1
state = 'E'
elif state == 'D':
if tape[pos] == 0:
tape[pos] = 0
pos-=1
state = 'E'
elif tape[pos] == 1:
tape[pos] = 0
pos-=1
state = 'D'
elif state == 'E':
if tape[pos] == 0:
tape[pos] = 0
pos+=1
state = 'A'
elif tape[pos] == 1:
tape[pos] = 1
pos+=1
state = 'C'
elif state == 'F':
if tape[pos] == 0:
tape[pos] = 1
pos-=1
state = 'A'
elif tape[pos] == 1:
tape[pos] = 1
pos+=1
state = 'A'
print tape
print sum(tape[x] == 1 for x in tape)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment