Update readme and lib and start 2015.

This commit is contained in:
2024-01-27 22:56:28 -05:00
parent b88d839bc1
commit d32bd4c04b
9 changed files with 181 additions and 6 deletions

53
2015/d5.py Normal file
View File

@@ -0,0 +1,53 @@
from lib import *
data = open(0).read()
part_1 = True
if part_1:
res = 0
for line in data.splitlines():
vc = 0
for c in line:
if c in "aoeui":
vc += 1
if vc < 3:
continue
prev = None
for c in line:
if c == prev:
break
prev = c
else:
continue
contains = False
ss = ["ab", "cd", "pq", "xy"]
for s in ss:
if s in line:
contains = True
if contains:
continue
res += 1
print(res)
else:
res = 0
for line in data.splitlines():
pairs = {}
for i in range(0, len(line) - 1):
p = line[i:i+2]
if p in pairs and i > pairs[p] + 1:
break
if not p in pairs:
pairs[p] = i
else:
continue
for i in range(0, len(line) - 2):
if line[i] == line[i + 2]:
break
else:
continue
res += 1
print(res)