Compare commits
No commits in common. "06fcf5f80cb65dac25fc59bc2304eb1e4079fbc7" and "7959e1186f8cca7a00f30865b610f4ce9025fa45" have entirely different histories.
06fcf5f80c
...
7959e1186f
@ -10,9 +10,9 @@ input_f = sys.argv[1]
|
|||||||
|
|
||||||
def pp(x):
|
def pp(x):
|
||||||
for i in x:
|
for i in x:
|
||||||
print(nodes[i].value,nodes[i].left,nodes[i].right)
|
for j in i:
|
||||||
|
print(j)
|
||||||
|
print()
|
||||||
|
|
||||||
d, *maps = open(input_f).read().split('\n')
|
d, *maps = open(input_f).read().split('\n')
|
||||||
|
|
||||||
@ -51,30 +51,11 @@ try:
|
|||||||
except:
|
except:
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def done(x):
|
|
||||||
print(x)
|
|
||||||
for i in x:
|
|
||||||
if not i.endswith('Z'):
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
pp(nodes)
|
current = {}
|
||||||
|
|
||||||
current = []
|
|
||||||
for i in nodes:
|
for i in nodes:
|
||||||
if i.endswith('A'):
|
if i.endswith('A'):
|
||||||
current.append(i)
|
current[i] = i
|
||||||
count = 0
|
|
||||||
steps = 0
|
#while not current.endswith('Z'):
|
||||||
while not done(current):
|
|
||||||
steps += 1
|
|
||||||
for i in range(len(current)):
|
|
||||||
if d[count%len(d)] == 'L':
|
|
||||||
#print("Going left from " + str(current[i]) + " to " + str(nodes[current[i]].left))
|
|
||||||
current[i] = nodes[current[i]].left
|
|
||||||
else:
|
|
||||||
#print("Going right from " + str(current[i]) + " to " + str(nodes[current[i]].right))
|
|
||||||
current[i] = nodes[current[i]].right
|
|
||||||
count += 1
|
|
||||||
print(steps)
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user