# This program solves the Eight Queens problem. # This version prints all solutions. from ChessBoard import * # Places queens on the given board, # starting with the given column. def place_queens(board, col = 0): if not board.valid(): return elif col >= board.size(): print(board) else: for row in range(board.size()): board.place(row, col) # choose place_queens(board, col + 1) # explore board.remove(row, col) # un-choose return False def main(): size = int(input("Board size? ")) board = ChessBoard(size) print("Here are all solutions:") place_queens(board) main()