From 03e4e7597808127432a4e3b19edec871c825bb98 Mon Sep 17 00:00:00 2001 From: Mikael CAPELLE Date: Mon, 9 Dec 2024 10:33:28 +0100 Subject: [PATCH] Add TQDM to 2024 day 9. --- src/holt59/aoc/2024/day9.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/holt59/aoc/2024/day9.py b/src/holt59/aoc/2024/day9.py index 3ab9d39..ea1faaa 100644 --- a/src/holt59/aoc/2024/day9.py +++ b/src/holt59/aoc/2024/day9.py @@ -42,7 +42,7 @@ class Solver(BaseSolver): contents = contents_0.copy() - for block_start, block_length in blocks[::-1]: + for block_start, block_length in self.progress.wrap(blocks[::-1]): try: i_free = next( i_free @@ -54,11 +54,10 @@ class Solver(BaseSolver): free_start, free_length = frees[i_free] - for i in range(block_length): - contents[free_start + i], contents[block_start + i] = ( - contents[block_start + i], - None, - ) + contents[free_start : free_start + block_length] = contents[ + block_start : block_start + block_length + ] + contents[block_start : block_start + block_length] = [None] * block_length if free_length == block_length: del frees[i_free]