[Solved]Python Code Task 5 Task 4 Example Q37057863
python code:(only task 5 )
Task 4 example


For example: your program could do the following: Enter N: 4 Enter position of Queen 1 0 Enter position of Queen: 3 1 Enter position of Queen: 02 Enter position of Queen: 23 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0 Task 5: Modify your program in Task 4, so that it prints a message telling the user if their candidate solution is a correct solution to the N-Queens problem. You should write a function checkSolution that takes the list representing the candidate solution and returns True if the candidate solution is a correct solution and False otherwise. You may like to write additional functions that can be used by the function checkSolution. For example: your program could do the following: Enter N: 4 Enter position of Queen: 1 0 Enter position of Queen 3 1 Enter position of Queen 0 2 Enter position of Queen 2 3 0 0 1 0 10 00 0 0 0 1 0 1 0 0 This is a real solution to the problem. and another example. Enter N: 3 Enter position of Queen: 0 1 Enter position of Queen: 1 2 Enter position of Queen 2 0 0 1 0 0 0 1 1 0 0 This is not a real solution to the problem. Which representation was easier to print as a matrix? Which representation would make it easier to check if the candidate solution was a correct solution to the problem? Show transcribed image text For example: your program could do the following: Enter N: 4 Enter position of Queen 1 0 Enter position of Queen: 3 1 Enter position of Queen: 02 Enter position of Queen: 23 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0
Task 5: Modify your program in Task 4, so that it prints a message telling the user if their candidate solution is a correct solution to the N-Queens problem. You should write a function checkSolution that takes the list representing the candidate solution and returns True if the candidate solution is a correct solution and False otherwise. You may like to write additional functions that can be used by the function checkSolution. For example: your program could do the following: Enter N: 4 Enter position of Queen: 1 0 Enter position of Queen 3 1 Enter position of Queen 0 2 Enter position of Queen 2 3 0 0 1 0 10 00 0 0 0 1 0 1 0 0 This is a real solution to the problem. and another example. Enter N: 3 Enter position of Queen: 0 1 Enter position of Queen: 1 2 Enter position of Queen 2 0 0 1 0 0 0 1 1 0 0 This is not a real solution to the problem. Which representation was easier to print as a matrix? Which representation would make it easier to check if the candidate solution was a correct solution to the problem?
Expert Answer
Answer to For example: your program could do the following: Enter N: 4 Enter position of Queen 1 0 Enter position of Queen: 3 1 En… . . .
OR

