You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
614 B
Python

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))