37 lines
647 B
Python
Executable File
37 lines
647 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Advent Of Code 2020 - Day 2
|
|
|
|
"""
|
|
1-5 k: kkkkhkkkkkkkkkk
|
|
5-7 k: blkqhtxfgktdkxzkksk
|
|
"""
|
|
|
|
filename = "input.txt"
|
|
|
|
with open(filename) as f:
|
|
content = f.readlines()
|
|
#content = [x.strip() for x in content]
|
|
|
|
validPasswords = 0
|
|
|
|
for i in content:
|
|
line = i.split()
|
|
|
|
xMin = int(line[0].split("-")[0])
|
|
xMax = int(line[0].split("-")[1])
|
|
|
|
character = line[1].rstrip(":")
|
|
|
|
password = line[2]
|
|
|
|
count = 0
|
|
for c in password:
|
|
if c == character:
|
|
count = count + 1
|
|
|
|
if (count >= xMin) and (count <= xMax):
|
|
validPasswords = validPasswords + 1
|
|
|
|
print (validPasswords)
|