Skip to content

Commit b7571f4

Browse files
committed
add Day4 part one
1 parent 45a8a4f commit b7571f4

File tree

3 files changed

+984
-5
lines changed

3 files changed

+984
-5
lines changed

day4/day4.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# importing the module
2+
import doctest
3+
import regex as re
4+
5+
def solve_1(passport):
6+
print(passport)
7+
header_pattern = re.compile(r"[a-z][a-z][a-z]:")
8+
9+
present_headers=[m[:-1] for m in re.findall(header_pattern, passport)]
10+
11+
required_fields=['ecl', 'pid', 'eyr', 'hcl', 'byr', 'iyr', 'hgt']
12+
for i in required_fields:
13+
if i not in present_headers:
14+
return False
15+
return True
16+
17+
def main():
18+
f=open("input", "r")
19+
lines=f.read().split("\n\n")
20+
21+
valid_passport_amount=0
22+
for l in lines:
23+
valid_passport_amount+=int(solve_1(l))
24+
print(valid_passport_amount)
25+
26+
main()

0 commit comments

Comments
 (0)