← RoseCode

ROSECODE 189

Non attacking queens

Philippe_57721 · Programming ·

On a 5∗5 chessboard, there are 8 ways to place 3 white queens and 5 black queens so that no queen of a given color can attack a queen of another color. One position is +-+-+-+-+-+ |W|W| | | | +-+-+-+-+-+ | | | |B|B| +-+-+-+-+-+ | | | | |B| +-+-+-+-+-+ |W| | | | | +-+-+-+-+-+ | | |B|B| | +-+-+-+-+-+ How many ways are there to place 5 white queens and 6 black queens on a 6∗6 chessboard the same way? Answer format: Count/White queens positions/Black queens positions // For the 1st solution in lexicographic order. A position is given as : (i,j) where i, j are the row and column index starting from the upper left cell, index starting at 1 Example : 8/(1,1)(1,2)(4,1)/(2,4)(2,5)(3,5)(5,3)(5,4) // For 3 white and 5 black queens on a 5∗5 chessboard. [My timing: 40 sec]