Share your repls and programming experiences

← Back to all posts
Solution to N Queen Problem
fullstack11235 (0)

I'm proud of this as a I've just started learning Python. Absolutely loving it btw.

So, you choose any integer which becomes the side length of the square chess board as well as the number of queens. Be wary of entering in numbers larger than 11 as it will take some time...

In return you get all the candidates (in the backtracking process) that are solutions to the problem. The problem, for those who don't know yet, is to figure out all the positions of the queens on the chess board so that no queen can attack another queen.

For example, here is a solution when the user enters 4:


{ width=50% }