2015 day 6

This commit is contained in:
2024-12-15 21:10:05 +01:00
parent b4a23badc2
commit 1d5966de0f
4 changed files with 360 additions and 0 deletions

22
2015/day-6/part-2.py Normal file
View File

@@ -0,0 +1,22 @@
import os
import re
file_path = os.path.join(os.path.dirname(__file__), "./input.txt")
# file_path = os.path.join(os.path.dirname(__file__), "./test-input.txt")
input = open(file_path).read().strip()
lines = input.split("\n")
count = 0
for line in lines:
if not any(
[
len(re.findall(pair, line)) >= 2
for pair in {line[i] + line[i + 1] for i in range(len(line) - 1)}
]
) or not any([line[i + 2] == line[i] for i in range(len(line) - 2)]):
continue
count += 1
print(count)