first commit
This commit is contained in:
36
2020/02/02.py
Executable file
36
2020/02/02.py
Executable file
@ -0,0 +1,36 @@
|
||||
#!/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)
|
Reference in New Issue
Block a user