[Python/2016] Move solutions into .py files

This commit is contained in:
Felix Bargfeldt 2023-10-29 12:38:12 +01:00
parent 0269ad8fc3
commit 2514b1d11f
Signed by: Defelo
GPG key ID: 2A05272471204DD3
50 changed files with 1172 additions and 3386 deletions

27
Python/2016/18.py Normal file
View file

@ -0,0 +1,27 @@
from lib import *
input = read_input(2016, 18).strip()
def next_row(row):
return "".join(".^"[a != b] for a, b in zip("." + row[:-1], row[1:] + "."))
row = input
out = 0
for _ in range(40):
out += row.count(".")
row = next_row(row)
print(out)
def next_row(row):
return "".join(".^"[a != b] for a, b in zip("." + row[:-1], row[1:] + "."))
row = input
out = 0
for _ in range(400000):
out += row.count(".")
row = next_row(row)
print(out)