init commit

This commit is contained in:
2020-12-02 15:29:10 -05:00
commit eb435f92bd
4 changed files with 1273 additions and 0 deletions

32
2/2.py Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python3
from random import randrange
import sys
L = []
with open(sys.argv[1], 'r') as f:
L = f.readlines()
L = [x.strip().split(' ') for x in L]
# part 1
valid = 0
for i in L:
minmax = i[0].split('-')
minmax = [int(x) for x in i[0].split('-')]
char = i[1].strip(':')
count = i[2].count(char)
if count >= minmax[0] and count <= minmax[1]:
valid += 1
print(valid)
# part 2
valid = 0
for i in L:
minmax = i[0].split('-')
minmax = [int(x) for x in i[0].split('-')]
char = i[1].strip(':')
if (i[2][minmax[0] - 1] == char and i[2][minmax[1] - 1] != char) or \
(i[2][minmax[0] - 1] != char and i[2][minmax[1] - 1] == char):
valid += 1
print(valid)

1000
2/input.txt Normal file

File diff suppressed because it is too large Load Diff