Пример #1
0
 def is_solution_feasible(self, solution):
     if not solution.is_valid():
         return False
     return all(( (self.ll <= len(cluster) <= self.lu) and
                  (sum( (solution.instance.weights[cluster_elem]
                         for cluster_elem in cluster) ) <= self.eu)
                  for cluster in solution.clusters ))
Пример #2
0
 def test_solve_diagonal_4(self):
     diag_sudoku_grid_4 = '..7..5..2.......13.........9...8.7......7...5..2.......1..3.......54.......7....4'
     expected_solution_4 = '367415892295867413841329657953284761684173925172956348418632579739541286526798134'
     resp = solve(diag_sudoku_grid_4)
     if resp is not False:
         solution_4 = values_grid(resp)
         print('Expected: {}'.format(expected_solution_4))
         print('Solution: {}'.format(solution_4))
         print(display(grid_values(solution_4)))
         self.assertEquals(expected_solution_4, solution_4)
         self.assertTrue(is_valid(grid_values(solution_4)))
     else:
         print('Could not find a valid solution.')
Пример #3
0
def test_is_valid_anagram_key(passphrase, valid):
    anagram_key = lambda p: "".join(sorted(p))
    assert is_valid(passphrase, key=anagram_key) == valid
Пример #4
0
def test_is_valid(formula, result):
    assert is_valid(formula) == result
Пример #5
0
 def test_basic(self):
     self.assertEqual(is_valid('aabbcc'), True)
Пример #6
0
def test_is_valid(passphrase, valid):
    assert is_valid(passphrase) == valid
Пример #7
0
 def test_invalid_longer(self):
     self.assertEqual(is_valid('ibfdgaeadiaefgbhbdghhhbgdfgeiccbiehhfcggchgghadhdhagfbahhddgghbdehidbibaeaagaeeigffcebfbaieggabcfbiiedcabfihchdfabifahcbhagccbdfifhghcadfiadeeaheeddddiecaicbgigccageicehfdhdgafaddhffadigfhhcaedcedecafeacbdacgfgfeeibgaiffdehigebhhehiaahfidibccdcdagifgaihacihadecgifihbebffebdfbchbgigeccahgihbcbcaggebaaafgfedbfgagfediddghdgbgehhhifhgcedechahidcbchebheihaadbbbiaiccededchdagfhccfdefigfibifabeiaccghcegfbcghaefifbachebaacbhbfgfddeceababbacgffbagidebeadfihaefefegbghgddbbgddeehgfbhafbccidebgehifafgbghafacgfdccgifdcbbbidfifhdaibgigebigaedeaaiadegfefbhacgddhchgcbgcaeaieiegiffchbgbebgbehbbfcebciiagacaiechdigbgbghefcahgbhfibhedaeeiffebdiabcifgccdefabccdghehfibfiifdaicfedagahhdcbhbicdgibgcedieihcichadgchgbdcdagaihebbabhibcihicadgadfcihdheefbhffiageddhgahaidfdhhdbgciiaciegchiiebfbcbhaeagccfhbfhaddagnfieihghfbaggiffbbfbecgaiiidccdceadbbdfgigibgcgchafccdchgifdeieicbaididhfcfdedbhaadedfageigfdehgcdaecaebebebfcieaecfagfdieaefdiedbcadchabhebgehiidfcgahcdhcdhgchhiiheffiifeegcfdgbdeffhgeghdfhbfbifgidcafbfcd'),
             True)
Пример #8
0
 def test_invalid_long(self):
     self.assertEqual(is_valid('hfchdkkbfifgbgebfaahijchgeeeiagkadjfcbekbdaifchkjfejckbiiihegacfbchdihkgbkbddgaefhkdgccjejjaajgijdkd'),
             True)
Пример #9
0
 def test_invalid_multiple(self):
     self.assertEqual(is_valid('aabbccdeee'), False)
Пример #10
0
 def test_invalid_lets(self):
     self.assertEqual(is_valid('aabbccde'), False)
Пример #11
0
 def test_invalid_count(self):
     self.assertEqual(is_valid('aabbcccc'), False)