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