from aoc import AOCDay from typing import Any class Day(AOCDay): test_solutions_p1 = [] test_solutions_p2 = [] def part1(self) -> Any: img_string = self.input[0] img_width = 25 img_height = 6 layers = [] while len(img_string) > 0: layers.append([img_string[i*img_width:(i+1)*img_width] for i in range(img_height)]) img_string = img_string[(img_height*img_width):] min_zero = len(self.input[0]) min_index = -1 for i, x in enumerate(layers): zero_count = 0 for r in x: zero_count += r.count("0") if zero_count < min_zero: min_zero = zero_count min_index = i one_count = 0 two_count = 0 for x in layers[min_index]: one_count += x.count("1") two_count += x.count("2") return one_count * two_count def part2(self) -> Any: img_string = self.input[0] img_width = 25 img_height = 6 layers = [] while len(img_string) > 0: layers.append([img_string[i*img_width:(i+1)*img_width] for i in range(img_height)]) img_string = img_string[(img_height*img_width):] rows = [] for y in range(img_height): line = "" for x in range(img_width): z = 0 while layers[z][y][x] == "2": z += 1 line += " " if layers[z][y][x] == "0" else "#" rows.append(line) for x in rows: print(x) return "see image above"