Question
i found this problem intresting and needs to be done to learn something new At end i have pasted what i have coded so far
i found this problem intresting and needs to be done to learn something new
At end i have pasted what i have coded so far so description goes below :-
The eight queens puzzle is the problem of placing eight chess queens on an 88 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal (including all diagonals running from upper left corner to lower right corner and running from upper right corner to lower left corner). In this question, you are to count the number of ways to place (14 ) queens on a 1414 chessboard where the positions of {2,3,4} queens are already known. Test inputs begin with the number of test cases. Each test case contains pairs of positions of the x known queens. For example, "1 1 2 9 3 6 4 10" contains the positions of 4 queens, where the first queen is at first row first column, the second queen is at second row ninth column, and so on. For each test case, output one integer representing the number of ways to replace the remaining (14 ) queens.
Sample Input
3
1 1 2 9 3 6 4 10
1 9 12 8 8 5 2 7
2 10 10 3
Sample Output
39
32
2414
starter code : -
import sys
def fourteen_queen(pos):
return 0
num_case = int(sys.stdin.readline())
for _ in range(num_case):
s = sys.stdin.readline().split()
n, pos = len(s) // 2, []
for i in range(n):
pos.append((int(s[2*i]), int(s[2*i+1])))
print(fourteen_queen(pos))
You can use making text to be read from command line file by your own with values:;
3
1 1 2 9 3 6 4 10
1 9 12 8 8 5 2 7
2 10 10 3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started