first commit

This commit is contained in:
2020-12-02 12:34:15 +01:00
parent e7158639f6
commit f4c3aeabee
13 changed files with 1421 additions and 0 deletions

36
2020/02/02.py Executable file
View 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)