Example #1
0
 def test_naked_twins(self):
     self.dict_compare(solution.naked_twins(self.before_naked_twins_1),
                       self.possible_solutions_1[0])
     self.assertTrue(
         solution.naked_twins(self.before_naked_twins_1)
         in self.possible_solutions_1,
         "Your naked_twins function produced an unexpected board.")
Example #2
0
 def test_naked_twins2(self):
     print("test_naked_twins2")
     #self.maxDiff = None
     self.assertTrue(
         solution.naked_twins(self.before_naked_twins_2)
         in self.possible_solutions_2,
         "Your naked_twins function produced an unexpected board.")
 def test_naked_twins2(self):
     print("naked_twin2:", self.before_naked_twins_2)
     print("solution 2: ", self.possible_solutions_2)
     self.assertTrue(
         solution.naked_twins(self.before_naked_twins_2)
         in self.possible_solutions_2,
         "Your naked_twins function produced an unexpected board.")
Example #4
0
 def test_naked_twins1(self):
     x = solution.naked_twins(self.pa_case)
     print('Old')
     display(self.pa_case)
     print('Solved')
     display(x)
     self.assertTrue(x in "", "The test just passed")
 def test_naked_twins2(self):
     self.assertTrue(
         solution.naked_twins(self.before_naked_twins_2)
         in self.possible_solutions_2,
         "Your naked_twins function produced an unexpected board.")
     print("first one" if self.before_naked_twins_2 ==
           self.possible_solutions_2[0] else "second one")
Example #6
0
    def test_naked_twins(self):

        # given
        """
        5   367   9  | 478   2    47 | 367   1   468
        4   1237  23 | 178   5    6  | 2379 237   89
        8   1267  26 |  9    14   3  | 267  2467  5
        ---------------+---------------+---------------
        39   8    7  | 134  1349  2  |  5    36   16
        6    5    4  | 137  139  179 |  13   8    2
        23   23   1  |  5    6    8  |  4    9    7
        ---------------+---------------+---------------
        1   369   8  |  2   349   5  | 679  467  469
        7    29   25 |  6    8   149 | 129  245   3
        239   4   2356|  13   7    19 |  8   256  169
        """
        t_values = solution.eliminate(
            solution.grid_values(
                '5.9.2..1.4...56...8..9.3..5.87..25..654....82..15684971.82.5...7..68...3.4..7.8..'
            ))

        # when
        result = solution.naked_twins(t_values)

        self.assertEqual('9', result['D1'])
 def test_naked_twins(self):
     result = solution.naked_twins(self.before_naked_twins_1)
     solved_first_peer = solution.get_unique_board_set(solution.AssociatedNodes("H4"))
     solved_second_peer = solution.get_unique_board_set(solution.AssociatedNodes("H6"))
     solved_peers = [i for i in solved_first_peer + solved_second_peer if i != "H6" and i != "H4"]
     for i in solved_peers:
         self.assertTrue("17" not in result[i])
Example #8
0
 def test_naked_twins(self):
     # solution.display(self.before_naked_twins_1)
     solution.display(self.possible_solutions_1[1])
     self.assertTrue(
         solution.naked_twins(self.before_naked_twins_1)
         in self.possible_solutions_1,
         "Your naked_twins function produced an unexpected board.")
Example #9
0
 def test_naked_twins(self):
     print("start testing","first nt")
     solved=solution.naked_twins(before_naked_twins)
     print("solved nt")
     solution.display(solved)
     print("ideal nt")
     solution.display(after_naked_twins)
     self.assertEqual(solved, after_naked_twins)
Example #10
0
 def test_naked_twin_in_diagonal(self):
     values = self.get_simple_grid()
     values['B2'] = '49'
     values['E5'] = '49'
     values['F6'] = '2547'
     values = solution.naked_twins(values)
     self.assertEqual(values['F6'], '257')
     self.assert_grid_empty_except(values, ['B2', 'E5', 'F6'])
Example #11
0
 def test_naked_twin_in_square(self):
     values = self.get_simple_grid()
     values['A1'] = '12'
     values['A2'] = '12'
     values['B1'] = '123'
     values = solution.naked_twins(values)
     self.assertEqual(values['B1'], '3')
     self.assert_grid_empty_except(values, ['A1', 'A2', 'B1'])
Example #12
0
 def test_naked_twin_in_row(self):
     values = self.get_simple_grid()
     values['D4'] = '456'
     values['D5'] = '456'
     values['D6'] = '456'
     values['D7'] = '123456'
     values = solution.naked_twins(values)
     self.assertEqual(values['D7'], '123')
     self.assert_grid_empty_except(values, ['D4', 'D5', 'D6', 'D7'])
Example #13
0
 def test_naked_twins(self):
     self.grid.update({
         "B1": "12",
         "B2": "12",
         "B3": "1234",
         "B6": "9712",
     })
     reduced_grid = solution.naked_twins(self.grid)
     self.assertEqual(reduced_grid["B3"], "34")
     self.assertEqual(reduced_grid["B6"], "97")
Example #14
0
 def test_naked_twins2(self):
     print('\nExpected 1\n')
     utils.display(self.possible_solutions_2[0])
     print('\nExpected 2\n')
     utils.display(self.possible_solutions_2[1])
     print('\nMine before\n')
     utils.display(self.before_naked_twins_2)
     print('\nMine after\n')
     self.assertTrue(solution.naked_twins(self.before_naked_twins_2) in self.possible_solutions_2,
                     "Your naked_twins function produced an unexpected board.")
Example #15
0
 def test_naked_twin_in_column(self):
     values = self.get_simple_grid()
     values['A7'] = '4569'
     values['B7'] = '4569'
     values['C7'] = '4569'
     values['D7'] = '4569'
     values['E7'] = '257'
     values = solution.naked_twins(values)
     self.assertEqual(values['E7'], '27')
     self.assert_grid_empty_except(values, ['A7', 'B7', 'C7', 'D7', 'E7'])
Example #16
0
def display_naked_twins():
    solution.display(before_naked_twins_1)

    print()

    solution.display(possible_solutions_1[0])
    print()

    values = solution.naked_twins(before_naked_twins_1)
    solution.display(values)
Example #17
0
    def test_naked_twins(self):
        solution.display(self.before_naked_twins_1)

        for sol in self.possible_solutions_1:
            print(" \n \n \n ")
            solution.display(sol)

        twins = solution.naked_twins(self.before_naked_twins_1)
        print(" \n \n \n ")
        solution.display(twins)

        self.assertTrue(
            twins in self.possible_solutions_1,
            "Your naked_twins function produced an unexpected board.")
Example #18
0
    def test_naked_twins2(self):
        mySol = solution.naked_twins(self.before_naked_twins_2)
        """
        print('\n\n')
        utils.display(mySol)
        print('\n\n')
        for sol in self.possible_solutions_2:
            utils.display(sol)
            print('\n\n')
        """

        self.assertTrue(
            mySol in self.possible_solutions_2,
            "Your naked_twins function produced an unexpected board.")
Example #19
0
    def test_naked_twins2(self):
        #    print("QUestion")
        #    solution.display(self.before_naked_twins_2)
        #    print("Answer")
        #    solution.display(solution.naked_twins(self.before_naked_twins_2))

        #    print("SOLUTION:1")
        #    solution.display((self.possible_solutions_2[1]))
        #    print("SOLUTION:2")
        #    solution.display((self.possible_solutions_2[0]))

        self.assertTrue(
            solution.naked_twins(self.before_naked_twins_2)
            in self.possible_solutions_2,
            "Your naked_twins function produced an unexpected board.")
Example #20
0
    def test_naked_twins(self):
        #print(self.result_1)
        #print()
        #solution.display(self.sample_1)
        #print()
        twins = solution.naked_twins(self.sample_1)
        #print(twins)
        #print()
        #solution.display(twins)

        assert self.result_1 == twins

        print('testing...', self.result_1 == twins)
#        self.assertTrue(solution.naked_twins(self.sample_1) in self.result_1,
#                        "Your naked_twins function produced an unexpected board.")
Example #21
0
    def test_naked_twins(self):
        mySol = solution.naked_twins(self.before_naked_twins_1)
        """
        print('\n\n')
        print('Original Puzzle\n------------------------------------\n')
        utils.display(self.before_naked_twins_1)
        print('\n\n')
        
        
        print('My Solution\n------------------------------------\n')
        utils.display(mySol)
        print('\n\n')
        for sol in self.possible_solutions_1:
            print('Possible Solution\n------------------------------------\n')
            utils.display(sol)
            print('\n\n')
        """

        self.assertTrue(
            mySol in self.possible_solutions_1,
            "Your naked_twins function produced an unexpected board.")
Example #22
0
 def test_naked_twins4(self):
     print(self.test_4)
     print(solution.naked_twins(self.test_4))
Example #23
0
 def test_naked_twins3(self):
     solution.display(self.before_naked_twins_3)
     solution_3 = solution.naked_twins(self.before_naked_twins_3)
     print('')
     solution.display(solution_3)
Example #24
0
 def test_naked_twins_submit(self):
     puzzle = {
         "G7": "2345678",
         "G6": "1236789",
         "G5": "23456789",
         "G4": "345678",
         "G3": "1234569",
         "G2": "12345678",
         "G1": "23456789",
         "G9": "24578",
         "G8": "345678",
         "C9": "124578",
         "C8": "3456789",
         "C3": "1234569",
         "C2": "1234568",
         "C1": "2345689",
         "C7": "2345678",
         "C6": "236789",
         "C5": "23456789",
         "C4": "345678",
         "E5": "678",
         "E4": "2",
         "F1": "1",
         "F2": "24",
         "F3": "24",
         "F4": "9",
         "F5": "37",
         "F6": "37",
         "F7": "58",
         "F8": "58",
         "F9": "6",
         "B4": "345678",
         "B5": "23456789",
         "B6": "236789",
         "B7": "2345678",
         "B1": "2345689",
         "B2": "1234568",
         "B3": "1234569",
         "B8": "3456789",
         "B9": "124578",
         "I9": "9",
         "I8": "345678",
         "I1": "2345678",
         "I3": "23456",
         "I2": "2345678",
         "I5": "2345678",
         "I4": "345678",
         "I7": "1",
         "I6": "23678",
         "A1": "2345689",
         "A3": "7",
         "A2": "234568",
         "E9": "3",
         "A4": "34568",
         "A7": "234568",
         "A6": "23689",
         "A9": "2458",
         "A8": "345689",
         "E7": "9",
         "E6": "4",
         "E1": "567",
         "E3": "56",
         "E2": "567",
         "E8": "1",
         "A5": "1",
         "H8": "345678",
         "H9": "24578",
         "H2": "12345678",
         "H3": "1234569",
         "H1": "23456789",
         "H6": "1236789",
         "H7": "2345678",
         "H4": "345678",
         "H5": "23456789",
         "D8": "2",
         "D9": "47",
         "D6": "5",
         "D7": "47",
         "D4": "1",
         "D5": "36",
         "D2": "9",
         "D3": "8",
         "D1": "36"
     }
     solution.display(puzzle)
     expected = {
         'G7': '2345678',
         'G6': '1236789',
         'G5': '23456789',
         'G4': '345678',
         'G3': '1234569',
         'G2': '12345678',
         'G1': '23456789',
         'G9': '24578',
         'G8': '345678',
         'C9': '124578',
         'C8': '3456789',
         'C3': '1234569',
         'C2': '1234568',
         'C1': '2345689',
         'C7': '2345678',
         'C6': '236789',
         'C5': '23456789',
         'C4': '345678',
         'E5': '68',
         'E4': '2',
         'F1': '1',
         'F2': '24',
         'F3': '24',
         'F4': '9',
         'F5': '37',
         'F6': '37',
         'F7': '58',
         'F8': '58',
         'F9': '6',
         'B4': '345678',
         'B5': '23456789',
         'B6': '236789',
         'B7': '2345678',
         'B1': '2345689',
         'B2': '1234568',
         'B3': '1234569',
         'B8': '3456789',
         'B9': '124578',
         'I9': '9',
         'I8': '345678',
         'I1': '2345678',
         'I3': '23456',
         'I2': '2345678',
         'I5': '2345678',
         'I4': '345678',
         'I7': '1',
         'I6': '23678',
         'A1': '2345689',
         'A3': '7',
         'A2': '234568',
         'E9': '3',
         'A4': '34568',
         'A7': '234568',
         'A6': '23689',
         'A9': '2458',
         'A8': '345689',
         'E7': '9',
         'E6': '4',
         'E1': '567',
         'E3': '56',
         'E2': '567',
         'E8': '1',
         'A5': '1',
         'H8': '345678',
         'H9': '24578',
         'H2': '12345678',
         'H3': '1234569',
         'H1': '23456789',
         'H6': '1236789',
         'H7': '2345678',
         'H4': '345678',
         'H5': '23456789',
         'D8': '2',
         'D9': '47',
         'D6': '5',
         'D7': '47',
         'D4': '1',
         'D5': '6',
         'D2': '9',
         'D3': '8',
         'D1': '36'
     }
     result = solution.naked_twins(puzzle)
     print("______________________\n")
     solution.display(result)
     self.assertEqual(expected, result)
Example #25
0
 def test_naked_twins3(self):
     self.assertTrue(
         solution.naked_twins(self.before_naked_twins_3)
         in self.possible_solutions_2,
         "Your naked_twins function produced an unexpected board.")
Example #26
0
 def test_naked_twins2(self):
     s_err = 'Your naked_twins function produced an unexpected board.'
     self.assertTrue(solution.naked_twins(self.before_naked_twins_2) in
                     self.possible_solutions_2, s_err)
Example #27
0
 def test_naked_twins3(self):
     result = solution.naked_twins(self.before_naked_twins_3)
     print(result)
Example #28
0
 def test_solve_naked_twins(self):
     before_naked_twins1 = '9.1....8.8.5.7..4.2.4....6...7......5..............83.3..6......9................'
     expected_solution = '9.1....8.8.5.7..4.2.4....6...7......5..............83.3..6......9................'
     solution = values_grid(naked_twins(grid_values(before_naked_twins1)))
     self.assertEquals(solution, expected_solution)
Example #29
0
 def test_naked_twins(self):
     self.assertEqual(solution.naked_twins(before_naked_twins), after_naked_twins)
 def test_naked_twins2(self):
     self.assertTrue(solution.naked_twins(self.before_naked_twins_2) in self.possible_solutions_2,
                     "Your naked_twins function produced an unexpected board.")
 def test_naked_twins(self):
     self.assertEqual(solution.naked_twins(before_naked_twins),
                      after_naked_twins)
Example #32
0
 def test_naked_twins2(self):
   #solution.display(solution.naked_twins(self.before_naked_twins_2))
   #print('8888888888888888888888888888')
   #solution.display(self.possible_solutions_2[0])
   self.assertTrue(solution.naked_twins(self.before_naked_twins_2) in self.possible_solutions_2,
                   "Your naked_twins function produced an unexpected board.")