This commit is contained in:
Ethanell 2019-12-04 10:09:53 +01:00
parent 0de0789714
commit 4a990c1f6c
2 changed files with 24 additions and 0 deletions

1
2019/day 4/P2/input.txt Normal file
View file

@ -0,0 +1 @@
246540-787419

23
2019/day 4/P2/password.py Normal file
View file

@ -0,0 +1,23 @@
pswrange = [int(i) for i in open("input.txt").read().split("-")]
valid = 0
for i in range(pswrange[0], pswrange[1]):
i = str(i)
l = list(i)
c = 0
dec = False
double = False
while c < len(l)-1:
if l[c] <= l[c+1]:
pass
else:
dec = True
break
if f"{l[c]}{l[c]}" in i and not f"{l[c]}{l[c]}{l[c]}" in i:
double = True
c+=1
if not dec and double:
valid+=1
print(valid)