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)} for char in puzzle_input: [d_x, d_y] = MOVEMENTS[char] coords = (coords[0] + d_x, coords[1] + d_y) delivered_houses.add(coords) print(delivered_houses) print(len(delivered_houses))