parent
4021a73746
commit
68525204f4
2 changed files with 6 additions and 5 deletions
@ -1,11 +1,12 @@ |
||||
input = [[int(i) for i in l.split()] for l in open("input.txt", 'r').read().splitlines()] |
||||
score = 0 |
||||
|
||||
|
||||
def diff(l): |
||||
newList = [l[i+1] - l[i] for i in range(len(l)-1)] |
||||
return l[-1] + diff(newList) if set(newList) != {0} else l[-1] |
||||
|
||||
|
||||
score = sum(diff(l) for l in input) |
||||
score2 = sum(diff(l[::-1]) for l in input) |
||||
|
||||
print(score) |
||||
print(score2) |
Loading…
Reference in new issue