From 4f5178755ae81ebf25afc5d8cdf47ae5a78f76e9 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 22 Dec 2023 00:44:19 +0100 Subject: fixed stoopid elves (pizza was great btw) --- 2023/21/solve.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to '2023/21/solve.py') diff --git a/2023/21/solve.py b/2023/21/solve.py index a10340e..8c87408 100644 --- a/2023/21/solve.py +++ b/2023/21/solve.py @@ -53,19 +53,15 @@ while q: pre[n] += 1 print(part1) -print(pre) poly = {} -for i in range(PREHEAT): - j = C + i * W - if j % 2: - poly[i] = pre[j] +for i, p in pre.items(): + if (i + 1) % W == C: + poly[i + 1] = p -print(poly) f = Polynomial.fit(list(poly.keys()), list(poly.values()), 2) -x = (FIN - C) / W -res = f(x) -print(f, x, round(res)) +res = f(FIN) +print(f, round(res)) # for i in range(PREHEAT, (FIN - C) / W + 1): # poly.append(predict(poly)) -- cgit v1.2.3