From 781e4cd6e1df88e36c710b3264f08f56e98cd047 Mon Sep 17 00:00:00 2001 From: Mikael CAPELLE Date: Tue, 10 Dec 2024 16:22:03 +0100 Subject: [PATCH] Remove bad print in 2023 day 21. --- src/holt59/aoc/2023/day21.py | 49 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/holt59/aoc/2023/day21.py b/src/holt59/aoc/2023/day21.py index f5c3057..84ddd68 100644 --- a/src/holt59/aoc/2023/day21.py +++ b/src/holt59/aoc/2023/day21.py @@ -102,32 +102,31 @@ class Solver(BaseSolver): # depending on the number of cycles, either A or B will be in the center # - counts = [ - [ - sum( - (i, j) in tiles - for i in range(ci * cycle, (ci + 1) * cycle) - for j in range(cj * cycle, (cj + 1) * cycle) - ) - for cj in range(-2, 3) - ] - for ci in range(-2, 3) - ] + # counts = [ + # [ + # sum( + # (i, j) in tiles + # for i in range(ci * cycle, (ci + 1) * cycle) + # for j in range(cj * cycle, (cj + 1) * cycle) + # ) + # for cj in range(-2, 3) + # ] + # for ci in range(-2, 3) + # ] - radius = (26501365 - rhombus) // cycle - 1 - A = counts[2][2] if radius % 2 == 0 else counts[2][1] - B = counts[2][2] if radius % 2 == 1 else counts[2][1] - answer_2 = ( - (radius + 1) * A - + radius * B - + 2 * radius * (radius + 1) // 2 * A - + 2 * radius * (radius - 1) // 2 * B - + sum(counts[i][j] for i, j in ((0, 2), (-1, 2), (2, 0), (2, -1))) - + sum(counts[i][j] for i, j in ((0, 1), (0, 3), (-1, 1), (-1, 3))) - * (radius + 1) - + sum(counts[i][j] for i, j in ((1, 1), (1, 3), (-2, 1), (-2, 3))) * radius - ) - print(f"answer 2 (v1) is {answer_2}") + # radius = (26501365 - rhombus) // cycle - 1 + # A = counts[2][2] if radius % 2 == 0 else counts[2][1] + # B = counts[2][2] if radius % 2 == 1 else counts[2][1] + # answer_2 = ( + # (radius + 1) * A + # + radius * B + # + 2 * radius * (radius + 1) // 2 * A + # + 2 * radius * (radius - 1) // 2 * B + # + sum(counts[i][j] for i, j in ((0, 2), (-1, 2), (2, 0), (2, -1))) + # + sum(counts[i][j] for i, j in ((0, 1), (0, 3), (-1, 1), (-1, 3))) + # * (radius + 1) + # + sum(counts[i][j] for i, j in ((1, 1), (1, 3), (-2, 1), (-2, 3))) * radius + # ) # version 2: fitting a polynomial #