def test_diagonal_positions_from_the_middle_of_the_board(self):
     result = get_diagonal_positions('d5')
     expected_indexes = [
         'c6', 'b7', 'a8',      # to top left
         'c4', 'b3', 'a2',      # to bottom left 
         'e6', 'f7', 'g8',      # to top right
         'e4', 'f3', 'g2', 'h1' # to bottom right
     ]
     self.assertEquals(set(expected_indexes), set(result))
Example #2
0
def find_safe_positions(queen_positions, safe_positions):
    safe_positions = set(safe_positions)
    for queen_position in queen_positions:
        column, row = to_coordinate_pair(queen_position)
        all_positions_in_the_column = positions_in_the_same_column(column) 
        all_positions_in_the_row = positions_in_the_same_row(row) 
        all_diagonal_positions = get_diagonal_positions(queen_position)
        safe_positions = safe_positions - set(all_positions_in_the_column)
        safe_positions = safe_positions - set(all_positions_in_the_row)
        safe_positions = safe_positions - set(all_diagonal_positions)
    return safe_positions
 def test_diagonal_positions_from_the_corner(self):
     result = get_diagonal_positions('a1')
     expected_indexes = ['b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8']
     self.assertEquals(set(expected_indexes), set(result))