[Python/2016] Move solutions into .py files
This commit is contained in:
parent
0269ad8fc3
commit
2514b1d11f
50 changed files with 1172 additions and 3386 deletions
27
Python/2016/18.py
Normal file
27
Python/2016/18.py
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue