Ejemplo n.º 1
0
 def test_cubes_pair_bigger(self):
     assert CubesPair(Cube([1, 2, 3, 4, 5, 7]), Cube(
         [1, 2, 3, 4, 5, 6])) > CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                                          Cube([1, 2, 3, 4, 5, 8]))
     assert CubesPair(Cube([1, 2, 3, 4, 5, 6]), Cube(
         [1, 3, 4, 5, 6, 8])) > CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                                          Cube([1, 2, 3, 4, 5, 8]))
Ejemplo n.º 2
0
 def test_get_all_combinations_from_leaves(self):
     s = solution(["01", "29"])
     filtered = s.getAllCombinationsFromLeaves()
     assert not CubesPair(Cube([0, 6, 9]), Cube([1, 2])) in filtered
     assert CubesPair(Cube([0, 2]), Cube([1, 6])) in filtered
     assert CubesPair(Cube([0, 2]), Cube([1, 9])) in filtered
     assert CubesPair(Cube([0, 6]), Cube([1, 2])) in filtered
     assert CubesPair(Cube([0, 9]), Cube([1, 2])) in filtered
Ejemplo n.º 3
0
    def test_all_sixnine_variants(self):

        assert CubesPair(Cube([1, 6]), Cube([1, 6])) in CubesPair(
            Cube([1, 6]), Cube([1, 6])).allSixNineVariants()
        assert CubesPair(Cube([1, 9]), Cube([1, 6])) in CubesPair(
            Cube([1, 6]), Cube([1, 6])).allSixNineVariants()
        assert CubesPair(Cube([1, 9]), Cube([1, 9])) in CubesPair(
            Cube([1, 6]), Cube([1, 6])).allSixNineVariants()
        assert CubesPair(Cube([1, 6]), Cube([1, 9])) in CubesPair(
            Cube([1, 6]), Cube([1, 6])).allSixNineVariants()
Ejemplo n.º 4
0
 def test_cubes_pair_in(self):
     assert CubesPair(Cube([1, 2, 3]),
                      Cube([1, 2])) in CubesPair(Cube([1, 2]), Cube([1, 2]))
     assert not CubesPair(Cube([4, 5]), Cube([1, 2])) in CubesPair(
         Cube([1, 2]), Cube([1, 2]))
     assert CubesPair(Cube([0, 1, 4]),
                      Cube([0])) in CubesPair(Cube([1, 4]), Cube([0]))
Ejemplo n.º 5
0
    def test_tree_set_cubes_pair(self):
        c1 = Cube([0, 4])
        c2 = Cube([0, 4])
        c3 = Cube([])
        c4 = Cube([0, 1, 4])

        t1 = tree(CubesPair(c3, c4))
        t2 = tree(CubesPair(c1, c2))
        t3 = tree(CubesPair(c1, c2))
        t4 = tree(CubesPair(c2, c1))

        a1 = []
        a1.append(t1)
        a1.append(t2)

        a2 = []
        a2.append(t3)
        a2.append(t4)

        assert len(set(a1)) == 2
        assert len(set(a2)) == 1

        t5 = tree(CubesPair(Cube([0, 1, 4]), Cube([0])))
        t6 = tree(CubesPair(Cube([0]), Cube([0, 1, 4])))

        assert len(set([t5, t6])) == 1
Ejemplo n.º 6
0
 def test_is_proper_pair(self):
     s = solution(solution.SQUARES)
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([0, 1, 3, 4, 5, 7])))
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([0, 1, 3, 4, 5, 8])))
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([0, 3, 4, 5, 8, 9])))
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([1, 3, 4, 5, 7, 9])))
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([1, 3, 4, 5, 8, 9])))
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([0, 1, 3, 4, 5, 7])))
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([1, 3, 4, 5, 6, 7])))
     assert s.isProperPair(
         CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6, 7])))
     assert s.isProperPair(
         CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6, 7])))
     assert s.isProperPair(
         CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 3, 8, 9])))
Ejemplo n.º 7
0
 def test_solution_missing(self):
     s = solution(solution.SQUARES)
     res = s.getAllCombinations()
     assert (CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([0, 1, 3, 4, 5,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([0, 3, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([1, 3, 4, 5, 7,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([1, 3, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([0, 1, 3, 4, 5,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([1, 3, 4, 5, 6,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6,
                                                       7]))) in res
Ejemplo n.º 8
0
 def test_cubes_unique_in_set(self):
     assert len(
         set([
             CubesPair(Cube([1, 2, 3, 4, 5, 6]), Cube([1, 2, 3, 4, 5, 6])),
             CubesPair(Cube([1, 2, 3, 4, 5, 6]), Cube([1, 2, 3, 4, 5, 6]))
         ])) == 1
     assert len(
         set([
             CubesPair(Cube([1, 2, 3, 4, 5, 6]), Cube([1, 2, 3, 4, 5, 6])),
             CubesPair(Cube([1, 2, 7, 4, 5, 6]), Cube([1, 2, 3, 4, 5, 6]))
         ])) == 2
     assert len(
         set([
             CubesPair(Cube([]), Cube([1, 3, 4, 5, 6, 8])),
             CubesPair(Cube([1, 3, 4, 5, 6, 8]), Cube([]))
         ])) == 1
Ejemplo n.º 9
0
 def test_cubes_pair_all_variants(self):
     assert CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                      Cube([1, 2, 3, 4, 5,
                            6])) in CubesPair(Cube([1, 2, 3, 4, 5]),
                                              Cube([1, 2, 3, 4, 5,
                                                    6])).allVariants()
     assert CubesPair(Cube([1, 2, 3, 4, 5, 7]),
                      Cube([1, 2, 3, 4, 5,
                            6])) in CubesPair(Cube([1, 2, 3, 4, 5]),
                                              Cube([1, 2, 3, 4, 5,
                                                    6])).allVariants()
     assert CubesPair(Cube([1, 2, 3, 4, 5, 8]),
                      Cube([1, 2, 3, 4, 5,
                            6])) in CubesPair(Cube([1, 2, 3, 4, 5]),
                                              Cube([1, 2, 3, 4, 5,
                                                    6])).allVariants()
     assert CubesPair(Cube([1, 2, 3, 4, 5, 9]),
                      Cube([1, 2, 3, 4, 5,
                            6])) in CubesPair(Cube([1, 2, 3, 4, 5]),
                                              Cube([1, 2, 3, 4, 5,
                                                    6])).allVariants()
     assert CubesPair(Cube([1, 2, 3, 4, 5, 9]),
                      Cube([1, 2, 3, 4, 5,
                            6])) in CubesPair(Cube([1, 2, 3, 4]),
                                              Cube([1, 2, 3,
                                                    4])).allVariants()
     assert CubesPair(Cube([1, 2, 3, 4, 5, 9]),
                      Cube([1, 2, 3, 4,
                            5, 6])) in CubesPair(Cube([1]),
                                                 Cube([1, 2, 3,
                                                       4])).allVariants()
     assert CubesPair(Cube([1, 2, 3, 4, 5, 9]),
                      Cube([1, 2, 3, 4, 5,
                            6])) in CubesPair(Cube([]),
                                              Cube([])).allVariants()
Ejemplo n.º 10
0
 def test_cubes_pair_equals(self):
     assert CubesPair(Cube([1, 2, 3, 4, 5, 7]),
                      Cube([1, 2, 3, 4, 5,
                            6])) == CubesPair(Cube([1, 2, 3, 4, 5, 7]),
                                              Cube([1, 2, 3, 4, 5, 6]))
     assert CubesPair(Cube([1, 2, 3, 4, 5, 7]),
                      Cube([1, 2, 3, 4, 5,
                            6])) == CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                                              Cube([1, 2, 3, 4, 5, 7]))
     assert CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                      Cube([1, 2, 3, 4, 5,
                            7])) == CubesPair(Cube([1, 2, 3, 4, 5, 7]),
                                              Cube([1, 2, 3, 4, 5, 6]))
     assert not CubesPair(Cube([1, 2, 3, 4, 5, 7]), Cube(
         [1, 2, 3, 4, 5, 6])) == CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                                           Cube([1, 2, 3, 4, 5, 8]))
     assert CubesPair(Cube([1, 3, 4, 5, 6, 8]),
                      Cube([1, 2, 3, 4, 5,
                            6])) == CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                                              Cube([1, 3, 4, 5, 6, 8]))
     assert not CubesPair(Cube([1, 2, 3, 4, 5, 6]), Cube(
         [1, 2, 3, 4, 5, 6])) == CubesPair(Cube([1, 3, 4, 5, 6, 8]),
                                           Cube([1, 2, 3, 4, 5, 6]))
     assert not CubesPair(Cube([1, 3, 4, 5, 6, 8]), Cube(
         [1, 2, 3, 4, 5, 6])) == CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                                           Cube([1, 2, 3, 4, 5, 6]))
     assert CubesPair(Cube([1, 2, 3, 4, 5, 6]),
                      Cube([1, 2, 3, 4, 5,
                            6])).getCubes()[0] == Cube([1, 2, 3, 4, 5, 6])
Ejemplo n.º 11
0
 def test_cubes_pair_str(self):
     assert str(
         CubesPair(Cube([1, 2, 3, 8, 5, 6]),
                   Cube([1, 2, 3, 6, 5,
                         4]))) == "{[1, 2, 3, 5, 6, 8], [1, 2, 3, 4, 5, 6]}"
Ejemplo n.º 12
0
 def test_possible_solutions(self):
     s = solution(solution.SQUARES)
     res = s.getAllCombinations()
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 3, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 4, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 3, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 4, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 7, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 6, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 3, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 5, 7, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 5, 6, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 2, 3, 4, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 2, 3, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 2, 3, 7, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 2, 3, 6, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 5, 6, 9]), Cube([1, 3, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([0, 1, 3, 4, 5,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([1, 2, 3, 4, 5,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 7, 8, 9]), Cube([1, 3, 4, 5, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 9]), Cube([0, 1, 3, 4, 5,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 9]), Cube([0, 3, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 9]), Cube([1, 3, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 8, 9]), Cube([0, 1, 3, 4, 5,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 8, 9]), Cube([0, 1, 3, 4, 5,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 8, 9]), Cube([0, 1, 3, 4, 5,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 8, 9]), Cube([0, 3, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 7,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 5, 7,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 5, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 5, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 7, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 6, 7,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 6, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 5,
                                                       6]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 3, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 4, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 6, 7,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 3, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 5, 6, 7,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 2, 3, 4, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 2, 3, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 2, 3, 6, 7,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 5, 6, 9]), Cube([1, 3, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([0, 1, 3, 4, 5,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([0, 1, 3, 4, 5,
                                                       6]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([0, 3, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([1, 2, 3, 4, 5,
                                                       6]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([1, 3, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 8]), Cube([1, 3, 4, 5, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 9]), Cube([0, 3, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 7, 9]), Cube([1, 3, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 8, 9]), Cube([0, 1, 3, 4, 5,
                                                       6]))) in res
     assert (CubesPair(Cube([0, 1, 2, 6, 8, 9]), Cube([0, 3, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 5, 6,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 5, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 5, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 6, 7,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 6, 7,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 3, 5, 6, 8, 9]), Cube([1, 2, 4, 6, 8,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 5,
                                                       6]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 7, 8]), Cube([1, 2, 3, 4, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 5,
                                                       6]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 4, 5, 6, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 5, 6, 7, 8, 9]), Cube([1, 2, 3, 4, 5,
                                                       9]))) in res
     assert (CubesPair(Cube([0, 5, 6, 7, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       7]))) in res
     assert (CubesPair(Cube([0, 5, 6, 7, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       8]))) in res
     assert (CubesPair(Cube([0, 5, 6, 7, 8, 9]), Cube([1, 2, 3, 4, 6,
                                                       9]))) in res
Ejemplo n.º 13
0
 def test_get_all_combinations_from_leaves_exclude(self):
     s = solution(["06", "29"])
     filtered = s.getAllCombinationsFromLeaves()
     assert not CubesPair(Cube([9, 9]), Cube([0, 2])) in filtered
Ejemplo n.º 14
0
 def test_possible_solutions_from_small_set(self):
     s = solution(["01", "29"])
     res = s.getAllCombinations()
     assert (CubesPair(Cube([0, 1, 2, 3, 4, 5]), Cube([0, 1, 2, 3, 8,
                                                       9]))) in res
Ejemplo n.º 15
0
 def test_possible_solutions_excluded(self):
     s = solution(solution.SQUARES)
     res = s.getAllCombinations()
     assert not (CubesPair(Cube([1, 2, 4, 8, 9, 9]), Cube(
         [0, 1, 3, 5, 6, 9]))) in res