Finish day 2 part 1

This commit is contained in:
Ethanell 2020-12-02 08:52:10 +01:00
parent f1cbb14c3e
commit 952c7264fa
2 changed files with 1014 additions and 0 deletions

1000
2020/day 2/P1/input.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,14 @@
import re
password_re = re.compile(r"^([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)$")
passwords = [password_re.search(p).groups() for p in open("input.txt").read().split("\n")[:-1]]
n = 0
for p in passwords:
if int(p[0]) <= p[3].count(p[2]) <= int(p[1]):
n += 1
print(n)