Compare commits
2 Commits
7959e1186f
...
06fcf5f80c
Author | SHA1 | Date | |
---|---|---|---|
06fcf5f80c | |||
72daf18fe4 |
@ -10,9 +10,9 @@ input_f = sys.argv[1]
|
||||
|
||||
def pp(x):
|
||||
for i in x:
|
||||
for j in i:
|
||||
print(j)
|
||||
print()
|
||||
print(nodes[i].value,nodes[i].left,nodes[i].right)
|
||||
|
||||
|
||||
|
||||
d, *maps = open(input_f).read().split('\n')
|
||||
|
||||
@ -51,11 +51,30 @@ try:
|
||||
except:
|
||||
print()
|
||||
|
||||
def done(x):
|
||||
print(x)
|
||||
for i in x:
|
||||
if not i.endswith('Z'):
|
||||
return False
|
||||
return True
|
||||
|
||||
current = {}
|
||||
pp(nodes)
|
||||
|
||||
current = []
|
||||
for i in nodes:
|
||||
if i.endswith('A'):
|
||||
current[i] = i
|
||||
|
||||
#while not current.endswith('Z'):
|
||||
current.append(i)
|
||||
count = 0
|
||||
steps = 0
|
||||
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