Files
AdventOfCode2023/09/09-2a.py
2023-12-09 14:49:18 +01:00

15 lines
406 B
Python

#!/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]))