-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday6.py
executable file
·45 lines (42 loc) · 989 Bytes
/
day6.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python3
import time as time
#max
t = time.time()
#question one
result = 0
seen = []
with open('day6_input') as f:
for line in f:
if line == "\n":
result += len(seen)
seen = []
else:
for i in line[0:len(line)-1]:
seen.append(i) if i not in seen else seen
result += len(seen)
print(result)
#question two
result = 0
seen = []
new = True
with open('day6_input') as f:
for line in f:
if line == "\n":
result += len(seen)
seen = []
new = True
else:
seen_new = []
if new == True:
new = False
for i in line[0:len(line)-1]:
seen_new.append(i)
for i in line[0:len(line)-1]:
if i in seen:
seen_new.append(i)
seen = seen_new
result += len(seen)
print(result)
print("max")
print(time.time() - t)
print("")