Problem # 19 : Queens at peace
We've all played chess atleast we know how to. Anyway as you know the queen can move in a straight line across a row or down a column or diagonally ie all moves except that of a knight.
Suppose there is a chess board of size NxN it is possible to place N queens on it in such a manner that none of the queens can "kill" any other queen.
Write a sub-routine QUEENS(N) which displays a chess board of size N and places N queens on it so none of them can kill each other. Please note it is impossible to have such a situation on a chess board with less than 16 squares (less than a 4x4 board).
Sample Output
On a 8x8 chess board
8 queens should be placed as follows :-
Similarly QUEENS(4) should return
And QUEENS(13) should return