Day 8 part 1

This commit is contained in:
rain
2023-12-11 12:24:37 -06:00
parent fa9d3d23a1
commit 51f1d0907a
+22
View File
@@ -0,0 +1,22 @@
with open("../input.txt", "r") as fp:
instructions, *maze = fp.read().strip().split("\n\n")
maze = [x.split(' = ') for x in ''.join(maze).split('\n')]
map = {}
for i in maze:
map[i[0]] = (i[1][1:-1].split(', '))
camel = 'AAA'
steps = 0
while camel != 'ZZZ':
for i in instructions:
dir = 0
if i == 'R':
dir = -1
camel = map[camel][dir]
steps += 1
if camel == 'ZZZ':
break
print(steps)