Import from Nextcloud

This commit is contained in:
2021-05-02 22:39:13 +03:00
commit ef3988b942
10 changed files with 2775 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import re
with open('02-input') as f:
passwords = [row.strip() for row in f]
pattern = re.compile(r'(\d*)-(\d*) (\w): (.*)')
count = 0
for p in passwords:
if m := pattern.match(p):
n1, n2, l, p = m.groups()
c = p.count(l)
if int(n1)<=c<=int(n2):
count += 1
print(count)
count = 0
for p in passwords:
if m := pattern.match(p):
n1, n2, l, p = m.groups()
n1, n2 = int(n1)-1, int(n2)-1
if p[n1]==l and p[n2]!=l or p[n1]!=l and p[n2]==l:
count += 1
print(count)
+1000
View File
File diff suppressed because it is too large Load Diff