09-2a fertig
This commit is contained in:
14
09/09-2a.py
Normal file
14
09/09-2a.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
input_file = open("input", "r")
|
||||||
|
data = [[int(i) for i in line.strip().split()]for line in input_file]
|
||||||
|
input_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
def find_diff(val_list):
|
||||||
|
if val_list.count(0) == len(val_list):
|
||||||
|
return 0
|
||||||
|
return val_list[0]-find_diff([(val_list[i+1]-val_list[i]) for i in range(len(val_list)-1)])
|
||||||
|
|
||||||
|
|
||||||
|
print("Lösung:", sum([find_diff(d) for d in data]))
|
||||||
Reference in New Issue
Block a user