parent
aa3d90d771
commit
9e4cf3fbf5
1 changed files with 12 additions and 0 deletions
@ -0,0 +1,12 @@ |
||||
input = open("input.txt", 'r').read().splitlines() |
||||
instructions = input[0] |
||||
nodes = {l.split()[0]: (l.split()[2][1:-1], l.split()[3][:-1]) for l in input[2:]} |
||||
|
||||
steps = 0 |
||||
node = 'AAA' |
||||
|
||||
while node != 'ZZZ': |
||||
node = nodes[node][0] if instructions[steps % len(instructions)] == 'L' else nodes[node][1] |
||||
steps += 1 |
||||
|
||||
print(steps) |
Loading…
Reference in new issue