Example #1
0
 def test_2_by_any(self):
     code = "012345"
     expected = [
         ["0", "1"],
         ["2", "3"],
         ["4", "5"],
     ]
     self.assertListEqual(expected, split_to_dims(code, (2, None)))
Example #2
0
 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)))
Example #3
0
    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)
Example #4
0
 def do_split():
     split_to_dims(code, (2, 2, 2))
Example #5
0
 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)))