Question: Answer using python language thanks. Task 1a: n-Queens partial Useful material: In this task you may find it useful to reuse some of your code

Answer using python language thanks.

Answer using python language thanks. Task 1a: n-Queens partial Useful material: Inthis task you may find it useful to reuse some of your

Task 1a: n-Queens partial Useful material: In this task you may find it useful to reuse some of your code from Workshop 6. Write a program getPossible(partial, n) in Python that takes as input a list partial representing a partial solution to the n-Queens problem and a positive integer n representing the dimension of the nxn chessboard. The input list contains the positions of the Queens currently placed on the board (or is empty if no Queens have been placed). You should use the same list representation as you used in Task 3 of Workshop 6, that is, the entry partial[i] gives the row position of the Queen in column i. You may assume that the partial solution gives the positions of the Queens in the first i columns and that the other columns are empty. Your program should return a list containing possible row positions for a Queen to be placed in the next column on the board. (The index of the next column can be obtained by the length of partial.) For example: If your partial list is [5, 3] and n = 6, your program should return the list [0, 1], that is, a Queen could be placed at row 0 column 2, or row 1 column 2, of the board. If your partial list is empty and n = 5, your program should return the list [0, 1, 2, 3, 4]. If your list is [3, 1] and n = 4, your program should return an empty list. Task 1b: In order to test your program in Task 1a, write a function printTable(partial, board_size) so that it prints a table representing the chessboard. It should have q in entries where a queen is placed, x in entries where a Queen may be placed in the next column and 0 in all other entries. For example: If your list is [5, 3] and n = 6, your program should print: 00000 00000 000000 00000 000000 900000 If your program getPossible is correctly implemented, a Queen placed on a position marked 'X' cannot "attack any of the positions marked 'Q'. So you can check if 'X' marks a valid position. What else should you check for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!