diff --git a/2023/8.py b/2023/8.py new file mode 100644 index 0000000..be669e8 --- /dev/null +++ b/2023/8.py @@ -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) \ No newline at end of file