From 7a07eddf5394806f77b3e472eda3e7b2de05c643 Mon Sep 17 00:00:00 2001 From: Colin Sullivan Date: Sat, 10 Dec 2022 19:08:10 +0000 Subject: [PATCH] fixed last column logic --- src/advent_of_code/day10/part2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/advent_of_code/day10/part2.py b/src/advent_of_code/day10/part2.py index 5189a34..9b012b2 100644 --- a/src/advent_of_code/day10/part2.py +++ b/src/advent_of_code/day10/part2.py @@ -30,8 +30,11 @@ def get_pixel_val(sprite_location: np.ndarray, curr_cycle: int) -> str: + orig_cycle = curr_cycle if curr_cycle > 40: curr_cycle = curr_cycle % 40 + if curr_cycle == 0: + curr_cycle = 40 if any(sprite_location == curr_cycle - 1): pixel = "#" else: @@ -59,7 +62,7 @@ def print_screen(input_str: str) -> str: pixel_val = get_pixel_val(sprite_location, curr_cycle) pixels.append(pixel_val) sprite_location += instruction - return "".join(pixels) + return "".join(pixels).strip() if __name__ == "__main__":