PROGRAMMING:Eight queens problem with special conditions
In chess, the queen is the most powerful piece. She can walk horizontally, straightly and obliquely. In 1848, chess player Max Bessel put forward the famous eight queens problem, that is, in August × Eight queens are placed on the chessboard of 8, so that they cannot attack each other - that is, no two Queens can be in the same row, column or diagonal line.
**Ask the queen in the first row to put in the specified column, how many kinds of pendulum**
###Input format:
The first row is the Queen's column
###Output format:
The number of Solutions
###Input example:
Here is a set of inputs. For example:
```in
one
```
###Output example:
The corresponding output is given here. For example:
```out
four
```
answer:If there is no answer, please comment
```
#Board is a list to store the current status of the queen
def conflict(board,nextx):
nexty=len(board)
for i in range(nexty):
if abs(board[i]-nextx) in (0,nexty-i) :
return True
return False
def queens(num=8,board=[]):
for pos in range(num):
if not conflict(board,pos):
if len(board)==num-1:
yield [pos]
else:
for result in queens(num,board+[pos]):
yield [pos]+result
n=int(input())
print(len(list(queens(8,board=[n-1]))))
```
**Ask the queen in the first row to put in the specified column, how many kinds of pendulum**
###Input format:
The first row is the Queen's column
###Output format:
The number of Solutions
###Input example:
Here is a set of inputs. For example:
```in
one
```
###Output example:
The corresponding output is given here. For example:
```out
four
```
answer:If there is no answer, please comment
```
#Board is a list to store the current status of the queen
def conflict(board,nextx):
nexty=len(board)
for i in range(nexty):
if abs(board[i]-nextx) in (0,nexty-i) :
return True
return False
def queens(num=8,board=[]):
for pos in range(num):
if not conflict(board,pos):
if len(board)==num-1:
yield [pos]
else:
for result in queens(num,board+[pos]):
yield [pos]+result
n=int(input())
print(len(list(queens(8,board=[n-1]))))
```