BOARD_SIZE = 4
def under_attack(col, queens): #does the 2nd argument takes all possible solution from smaller_solution or it takes one by one?
left = right = col
for c, r in reversed (queens):
left, right = left - 1, right + 1
if r in (left, col, right):
return True
return False
def solve(n):
if n == 0:
return [[]]
smaller_solutions = solve(n - 1)
return [solution+[(n,i+1)]
for i in range(BOARD_SIZE)
for solution in smaller_solutions
if not under_attack(i+1, solution]
for answer in solve(BOARD_SIZE):
print (answer)