def test_2_by_any(self): code = "012345" expected = [ ["0", "1"], ["2", "3"], ["4", "5"], ] self.assertListEqual(expected, split_to_dims(code, (2, None)))
def test_1_by_2_by_any(self): code = "01234567" expected = [ [["0"], ["1"]], [["2"], ["3"]], [["4"], ["5"]], [["6"], ["7"]], ] self.assertListEqual(expected, split_to_dims(code, (1, 2, None)))
def main(): code = load_one("input/d08.txt", re.compile("[0-2]+")) layers = split_to_dims(code, (25, 6, None)) min_layer = min( layers, key=lambda layer: count_items_across_groups(layer)["0"]) pixel_count = count_items_across_groups(min_layer) print(pixel_count["1"] * pixel_count["2"]) for row in render((25, 6), layers): print(row)
def do_split(): split_to_dims(code, (2, 2, 2))
def test_2_by_2_by_2(self): code = "01234567" expected = [[["0", "1"], ["2", "3"]], [["4", "5"], ["6", "7"]]] self.assertListEqual(expected, split_to_dims(code, (2, 2, 2)))