19 lines
372 B
Python
Executable File
19 lines
372 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from useful import *
|
|
|
|
ns = [np.array(numbers(l), dtype=int) for l in lines(open(0))]
|
|
|
|
def solve(row):
|
|
if all(row == 0):
|
|
return 0
|
|
return row[-1] + solve(np.diff(row))
|
|
|
|
def twolve(row):
|
|
if all(row == 0):
|
|
return 0
|
|
return row[0] - twolve(np.diff(row))
|
|
|
|
print(sum(solve(n) for n in ns))
|
|
print(sum(twolve(n) for n in ns))
|