Exemplo n.º 1
0
def gen_orthogonal(n, i):
    sticker_matrix = [[
        Sticker(FaceEnum.FRONT, OrientEnum.UP) for _ in range(n)
    ] for _ in range(i)]
    for _ in range(n - i):
        sticker_matrix.append(
            [Sticker(FaceEnum.BACK, OrientEnum.DOWN) for _ in range(n)])
    return just(Face(n, flatten(sticker_matrix)))
Exemplo n.º 2
0
    def rotate_ccw_test(self):
        ccw_sticker_mat = []

        s00 = Sticker(FaceEnum.FRONT, OrientEnum.UP)
        s01 = Sticker(FaceEnum.RIGHT, OrientEnum.RIGHT)
        s02 = Sticker(FaceEnum.BACK, OrientEnum.DOWN)
        ccw_sticker_mat.append([s00, s01, s02])

        s10 = Sticker(FaceEnum.LEFT, OrientEnum.LEFT)
        s11 = Sticker(FaceEnum.UP, OrientEnum.UP)
        s12 = Sticker(FaceEnum.DOWN, OrientEnum.RIGHT)
        ccw_sticker_mat.append([s10, s11, s12])

        s20 = Sticker(FaceEnum.FRONT, OrientEnum.DOWN)
        s21 = Sticker(FaceEnum.RIGHT, OrientEnum.LEFT)
        s22 = Sticker(FaceEnum.BACK, OrientEnum.UP)
        ccw_sticker_mat.append([s20, s21, s22])

        ccw_comp_face = Face(*N_and_flatten(ccw_sticker_mat))

        sticker_mat = []

        sticker_row = [s20, s10, s00]
        sticker_mat.append([deepcopy(s).rotate_cw() for s in sticker_row])

        sticker_row = [s21, s11, s01]
        sticker_mat.append([deepcopy(s).rotate_cw() for s in sticker_row])

        sticker_row = [s22, s12, s02]
        sticker_mat.append([deepcopy(s).rotate_cw() for s in sticker_row])

        comp_face = Face(*N_and_flatten(sticker_mat))

        assert (comp_face.rotate_ccw() == ccw_comp_face
                ), f"failed for {str(comp_face)}\n{repr(comp_face)}"
Exemplo n.º 3
0
    def stickers_and_face(self):
        s1 = Sticker(FaceEnum.FRONT, OrientEnum.UP)
        s2 = Sticker(FaceEnum.BACK, OrientEnum.RIGHT)
        s3 = Sticker(FaceEnum.LEFT, OrientEnum.DOWN)
        stickers = [s1, s2, s3]

        cs = Sticker(FaceEnum.RIGHT, OrientEnum.LEFT)
        face_stickers = []
        face_stickers.append([cs, s1, cs])
        face_stickers.append([s1, s2, s3])
        face_stickers.append([cs, s3, cs])
        return stickers, Face(*N_and_flatten(face_stickers))
Exemplo n.º 4
0
    def rotate_ht_test(self):
        stickers = self.stickers()
        orig_slice = RowFaceSlice(stickers)
        face_slice = RowFaceSlice(deepcopy(stickers)).rotate_ht()
        assert isinstance(face_slice, RowFaceSlice)

        err_str = f"\n{repr(orig_slice)})\nto\n{repr(face_slice)}"
        sol_stickers = face_slice.stickers
        assert sol_stickers[0] == Sticker(FaceEnum.LEFT,
                                          OrientEnum.UP), err_str
        assert sol_stickers[1] == Sticker(FaceEnum.BACK,
                                          OrientEnum.LEFT), err_str
        assert sol_stickers[2] == Sticker(FaceEnum.FRONT,
                                          OrientEnum.DOWN), err_str
Exemplo n.º 5
0
 def face(self, stickers):
     s1, s2, s3 = stickers
     cs = Sticker(FaceEnum.RIGHT, OrientEnum.LEFT)
     face_stickers = []
     face_stickers.append([cs, s1, cs])
     face_stickers.append([s1, s2, s3])
     face_stickers.append([cs, s3, cs])
     return Face(face_stickers)
Exemplo n.º 6
0
 def front_face(self):
     sticker_matrix = []
     for i in range(3):
         row = [Sticker(FaceEnum.FRONT, OrientEnum.UP) for _ in range(3)]
         sticker_matrix.append(row)
     return Face(*N_and_flatten(sticker_matrix))
Exemplo n.º 7
0
def gen_c2_minus_c4_faces_4():
    stickers = [
        [
            Sticker(FaceEnum.BACK, OrientEnum.DOWN),
            Sticker(FaceEnum.FRONT, OrientEnum.UP),
            Sticker(FaceEnum.FRONT, OrientEnum.UP),
            Sticker(FaceEnum.BACK, OrientEnum.DOWN),
        ],
        [
            Sticker(FaceEnum.BACK, OrientEnum.DOWN),
            Sticker(FaceEnum.FRONT, OrientEnum.UP),
            Sticker(FaceEnum.FRONT, OrientEnum.UP),
            Sticker(FaceEnum.BACK, OrientEnum.DOWN),
        ],
        [
            Sticker(FaceEnum.BACK, OrientEnum.UP),
            Sticker(FaceEnum.FRONT, OrientEnum.DOWN),
            Sticker(FaceEnum.FRONT, OrientEnum.DOWN),
            Sticker(FaceEnum.BACK, OrientEnum.UP),
        ],
        [
            Sticker(FaceEnum.BACK, OrientEnum.UP),
            Sticker(FaceEnum.FRONT, OrientEnum.DOWN),
            Sticker(FaceEnum.FRONT, OrientEnum.DOWN),
            Sticker(FaceEnum.BACK, OrientEnum.UP),
        ],
    ]
    return just(Face(4, flatten(stickers)))
Exemplo n.º 8
0
 def test_repr(self, face_enum, orient_enum):
     sticker = Sticker(face_enum, orient_enum)
     sticker_repr = repr(sticker)
     orient_repr = repr(orient_enum)
     assert orient_repr in sticker_repr
Exemplo n.º 9
0
 def test_str(self, face_enum, orient_enum):
     sticker = Sticker(face_enum, orient_enum)
     gold = f"Sticker({face_enum}, {orient_enum})"
     assert str(sticker) == gold
Exemplo n.º 10
0
 def rotate_ht_test(self):
     sticker = Sticker(FaceEnum.FRONT, OrientEnum.UP)
     sticker.rotate_ht()
     assert sticker.init_face_enum == FaceEnum.FRONT
     assert sticker.orient_enum == OrientEnum.DOWN
Exemplo n.º 11
0
 def construction_test(self, face_enum, orient_enum):
     Sticker(face_enum, orient_enum)
Exemplo n.º 12
0
 def stickers(self):
     s1 = Sticker(FaceEnum.FRONT, OrientEnum.UP)
     s2 = Sticker(FaceEnum.BACK, OrientEnum.RIGHT)
     s3 = Sticker(FaceEnum.LEFT, OrientEnum.DOWN)
     return [s1, s2, s3]