예제 #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)))
예제 #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)))
예제 #3
0
파일: d08.py 프로젝트: LAHumphreys/AOC
    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)
예제 #4
0
 def do_split():
     split_to_dims(code, (2, 2, 2))
예제 #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)))