Compare commits

..

2 Commits

Author SHA1 Message Date
06fcf5f80c Working on 2023-12-08 p2 2023-12-08 16:56:49 +01:00
72daf18fe4 Working on 2023-12-08 p2 2023-12-08 16:56:35 +01:00

View File

@ -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)