From ccc19511e0f46180273ff905264cdfd6a9ddf7fc Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Fri, 8 Dec 2023 15:24:12 +0100 Subject: [PATCH] Trying 2023-12-08 p2 --- 2023/day8/part2.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/2023/day8/part2.py b/2023/day8/part2.py index fc0059e..6af6c80 100644 --- a/2023/day8/part2.py +++ b/2023/day8/part2.py @@ -39,16 +39,23 @@ for i in maps: r = i[12:15] nodes[s] = Node(s,l,r) -pprint(nodes) - current = 'AAA' steps = 0 -index = 0 -directions = d -while current != 'ZZZ': - steps += 1 - directions = directions[index] - if directions == 'L': +count = 0 +try: + while current != 'ZZZ': + steps += 1 + current = nodes[current].left if d[count%len(d)] == 'L' else nodes[current].right + count += 1 + print(steps) +except: + print() -print(steps) +current = {} +for i in nodes: + if i.endswith('A'): + current[i] = i + +#while not current.endswith('Z'): +