-
Notifications
You must be signed in to change notification settings - Fork 0
/
AoC2020_Day4_2.py
52 lines (34 loc) · 1.02 KB
/
AoC2020_Day4_2.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
46
47
48
49
50
51
52
#AoC Day 4, part 1- WORKS (kind of)
#separate entries by new lines
my_data = list(open('aoc2020_d4_data.txt'))
new_data = []
for alpha in my_data:
new_data.append(alpha.split())
#obtaining an entry
n = 0
valid = 0
def isvalid(n, new_datay):
counter = 0 #need 8 counters to = 1 validy
while new_datay[n]!=[]:
entry = new_datay[n]
counter_list = ['ecl', 'pid', 'eyr', 'hcl', 'byr', 'iyr', 'hgt']
for x in entry:
for y in counter_list:
if y in x:
counter+=1
if counter == 7:
validy =1
else:
validy = 0
n+=1
return validy, n
while True:
while new_data[n]!=[]:
vent, nan = isvalid(n, new_data)
n = nan
valid = valid + vent
if new_data[n] == []:
n+=1
print('valid entries = ', valid)
#This currently gives 205, but the correct answer is 206.
#Probably something to do with 'n' getting out of range.