I was asked the following question in an interview today and I've been thinking about it ever since. I was not able to answer it and haven't been able to find a solution online.
Given a chess board with dimensions X by Y and N queens, determine whether it is possible to arrange these queens on the board such that they cannot attack each other.
A 2 x 3 board with 2 queens does have a solution so the algorithm would return true:
Q . .
. . Q
I'm looking for a programming approach to this puzzle, not just ways to solve it on paper, for example.