bits from phosphorus as well

This commit is contained in:
2020-12-02 19:15:34 +00:00
parent c0a55c01ff
commit d68b80b8a2
5 changed files with 1019 additions and 0 deletions

6
02/1.py Normal file
View File

@ -0,0 +1,6 @@
lines = open("input", "r").read().split("\n")
import re
matches = [re.match(r"^([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)$", line) for line in lines]
matches = [m for m in matches if m is not None]
valids = [True for m in matches if int(m.group(1)) <= len([c for c in m.group(4) if c == m.group(3)]) <= int(m.group(2))]
print(len(valids))

6
02/2.py Normal file
View File

@ -0,0 +1,6 @@
lines = open("input", "r").read().split("\n")
import re
matches = [re.match(r"^([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)$", line) for line in lines]
matches = [m for m in matches if m is not None]
valids = [True for m in matches if (m.group(4)[int(m.group(1)) - 1] == m.group(3)) ^ (m.group(4)[int(m.group(2)) - 1] == m.group(3))]
print(len(valids))

1000
02/input Normal file

File diff suppressed because it is too large Load Diff

3
02/test Normal file
View File

@ -0,0 +1,3 @@
1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc