Day 08
This commit is contained in:
18
day08/part1.py
Normal file
18
day08/part1.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
|
||||
instructions = tuple(int(char == "R") for char in next(lines))
|
||||
next(lines)
|
||||
nodes = {line[:3]: (line[7:10], line[12:15]) for line in lines}
|
||||
|
||||
node = "AAA"
|
||||
cnt = 0
|
||||
|
||||
while True:
|
||||
for char in instructions:
|
||||
node = nodes[node][char]
|
||||
cnt += 1
|
||||
if node == "ZZZ":
|
||||
print(cnt)
|
||||
exit(0)
|
||||
Reference in New Issue
Block a user