Finished on 2023-12-09 p2

This commit is contained in:
FrederikBaerentsen 2023-12-09 19:41:13 +01:00
parent 00220ca406
commit 980acef762

View File

@ -13,38 +13,30 @@ t = []
def calc(line): def calc(line):
global t global t
t.append(line) t.append(line)
print(line)
diff = [] diff = []
for i in range(0,len(line)-1): for i in range(0,len(line)-1):
diff.append(line[i+1]-line[i]) diff.append(line[i+1]-line[i])
if not all(v == 0 for v in diff): if not all(v == 0 for v in diff):
last.append(diff[-1]) last.append(diff[-1])
calc(diff) calc(diff)
else:
print(diff)
return 0 return 0
prev = 0
result = [] result = []
left = []
for mdx,m in enumerate(maps): for mdx,m in enumerate(maps):
t = [] t = []
left = []
last = [] last = []
last.append(m[-1]) last.append(m[-1])
last.append(calc(m)) last.append(calc(m))
result.append(reduce(lambda x, y: x+y, last)) result.append(reduce(lambda x, y: x+y, last))
print(t)
pprint(last)
print(sum(result))
pprint(t)
tx = [] tx = []
tmp = 0
tmp = 0 for i in range(len(t)-1,-1,-1):
for i in range(len(t)-1,-1,-1):
tx.append(t[i][0]) tx.append(t[i][0])
tmp = t[i][0] - tmp tmp = t[i][0] - tmp
left.append(tmp)
print('Part 1: ' + str(sum(result)))
print('Part 2: ' + str(sum(left)))
print(tx)
print(tmp)