Example #1
0
    def test_path_to_happiness_05(self):
        # tall fields
        field = self.make_field(20, 5, lambda r, c: (r + c + 3) % 7)
        happiness = 30
        self.check_result(field, happiness,
                          quiz_resubmit.path_to_happiness(field.copy()))

        field = self.make_field(200, 4, lambda r, c: (r + c + 3) % 7)
        happiness = 24
        self.check_result(field, happiness,
                          quiz_resubmit.path_to_happiness(field.copy()))
Example #2
0
    def test_path_to_happiness_02(self):
        # a two column field
        field = {"nrows": 3, "ncols": 2, "smiles": ((6, 25), (5, 2), (4, 35))}
        happiness = 40
        result = quiz_resubmit.path_to_happiness(field)
        self.assertTrue(result == [1, 2])
        self.check_result(field, happiness, result)

        # a two column field with two solution paths; either is fine
        field = {"nrows": 3, "ncols": 2, "smiles": ((5, 18), (6, 0), (4, 18))}
        happiness = 24
        result = quiz_resubmit.path_to_happiness(field)
        self.assertTrue(result == [1, 0] or result == [1, 2])
        self.check_result(field, happiness, result)
Example #3
0
 def test_path_to_happiness_01(self):
     # single column field
     field = {"nrows": 3, "ncols": 1, "smiles": ((5, ), (6, ), (4, ))}
     happiness = 6
     result = quiz_resubmit.path_to_happiness(field)
     self.assertTrue(result == [1])
     self.check_result(field, happiness, result)
Example #4
0
 def test_path_to_happiness_03(self):
     # single row field
     field = {
         "nrows": 1,
         "ncols": 10,
         "smiles": ((5, 6, 4, 0, 5, 2, 1, 8, 9, 1), )
     }
     happiness = 41
     self.check_result(field, happiness,
                       quiz_resubmit.path_to_happiness(field.copy()))
Example #5
0
    def test_path_to_happiness_04(self):
        # small size fields
        field = {"nrows": 2, "ncols": 3, "smiles": ((100, 3, 5), (2, 4, 6))}
        happiness = 110
        self.check_result(field, happiness,
                          quiz_resubmit.path_to_happiness(field.copy()))

        field = self.make_field(5, 3, lambda r, c: (r + c + 2) % 4)
        happiness = 8
        self.check_result(field, happiness,
                          quiz_resubmit.path_to_happiness(field.copy()))

        field = self.make_field(4, 5, lambda r, c: abs(r - 2))
        happiness = 10
        self.check_result(field, happiness,
                          quiz_resubmit.path_to_happiness(field.copy()))

        field = self.make_field(5, 8, lambda r, c: 1 if r == c else 0)
        happiness = 5
        self.check_result(field, happiness,
                          quiz_resubmit.path_to_happiness(field.copy()))
Example #6
0
 def test_path_to_happiness_10(self):
     # larger field
     field = self.make_field(500, 600, lambda r, c: (r * c + r + c) % 7)
     happiness = 3600
     self.check_result(field, happiness,
                       quiz_resubmit.path_to_happiness(field.copy()))
Example #7
0
 def test_path_to_happiness_09(self):
     # large field
     field = self.make_field(47, 50, lambda r, c: (r * c) % 7)
     happiness = 217
     self.check_result(field, happiness,
                       quiz_resubmit.path_to_happiness(field.copy()))
Example #8
0
 def test_path_to_happiness_08(self):
     # medium size fields
     field = self.make_field(17, 12, lambda r, c: (r + c) % 7)
     happiness = 72
     self.check_result(field, happiness,
                       quiz_resubmit.path_to_happiness(field.copy()))
Example #9
0
 def test_path_to_happiness_07(self):
     # wide field with 3 rows
     field = self.make_field(3, 15, lambda r, c: (r + c + 2) % 4)
     happiness = 37
     self.check_result(field, happiness,
                       quiz_resubmit.path_to_happiness(field.copy()))
Example #10
0
 def test_path_to_happiness_06(self):
     # wide field with 2 rows
     field = self.make_field(2, 20, lambda r, c: (r + c + 2) % 4)
     happiness = 45
     self.check_result(field, happiness,
                       quiz_resubmit.path_to_happiness(field.copy()))