-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay3.py
31 lines (25 loc) · 809 Bytes
/
Day3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
fileHandle = open("/Users/waltergibbons/Desktop/Day3.txt")
contents = fileHandle.read()
location = [0,0]
dict = {}
print contents.__len__(), "Characters in file"
for i in range(0, contents.__len__()):
string = str(location)
if contents[i] == ">":
print "Santa moved right"
location[0] = location[0] + 1
dict[string] = 1;
elif contents[i] == "<":
print "Santa moved left"
location[0] = location[0] - 1
dict[string] = 1;
elif contents[i] == "^":
print "Santa moved up"
location[1] = location[1] + 1
dict[string] = 1;
elif contents[i] == "v":
print "Santa moved down"
location[1] = location[1] - 1
dict[string] = 1;
print dict.__len__(), "Houses Visited"
print "Final Location", location