1
0
Fork 0
advent-of-code/2015/aoc_d3p1.py

20 lines
516 B
Python
Raw Normal View History

2024-02-08 09:55:40 +01:00
#!/usr/bin/env python
visited_houses = []
current_house = (0, 0)
with open("inputd3.txt", "r") as f:
for input in f:
for x in input:
if x == "^":
current_house = (current_house[0] - 1, current_house[1])
elif x == "v":
current_house = (current_house[0] + 1, current_house[1])
elif x == ">":
current_house = (current_house[0], current_house[1] + 1)
else:
current_house = (current_house[0], current_house[1] - 1)
visited_houses.append(current_house)
print(len(set(visited_houses)))