advent-of-code/2015/03/part02.py

28 lines
614 B
Python
Raw Normal View History

2021-12-01 11:07:21 +01:00
with open("input") as f:
puzzle_input = f.read()
# puzzle_input = "^v^v^v^v^v"
coords = (0, 0)
delivered_houses = set()
delivered_houses.add(coords)
MOVEMENTS = {">": (1, 0), "^": (0, 1), "<": (-1, 0), "v": (0, -1)}
SANTA_MOVES = puzzle_input[::2]
ROBO_MOVES = puzzle_input[1::2]
for char in SANTA_MOVES:
[d_x, d_y] = MOVEMENTS[char]
coords = (coords[0] + d_x, coords[1] + d_y)
delivered_houses.add(coords)
coords = (0, 0)
for char in ROBO_MOVES:
[d_x, d_y] = MOVEMENTS[char]
coords = (coords[0] + d_x, coords[1] + d_y)
delivered_houses.add(coords)
print(len(delivered_houses))