# How do I solve this chessboard problem? [closed]

We are given a chessboard of size 'N' X 'N' . But it can contain any numbers of white-squares and black-squares , that too in any-order .

Say there are 'a'-squares of white color and 'b'-squares of black-color , then ,

[ a+b=n*n ]

We have to keep on making move with black-squares on the chessboard till there is no move left.

This is what happens in a move:-

1)We choose a black-square at co-ordinate:-(row,column) and move it to (row-1,column+1) , only if the co-ordinate (row-1,column+1) also contains a black-square . After it is moved to the new-position , the old-position,i.e, [row,column] becomes empty, i.e , its color turns to white .

OR

2)We choose a black-square at co-ordinate:-(row,column) and move it to (row-1,column-1) , only if the co-ordinate (row-1,column-1) also contains a black-square .After it is moved to the new-position , the old-position,i.e, [row,column] becomes empty, i.e , its color turns to white .

We have to end this game in least number of moves and the question is to find the sequence of those moves .

Lets denote black-square by '1' and white-square by '0' .. ...

Example:-

3X3 chessboard:-

0 1 0

1 0 1

0 0 0

Sequence of move(s) which ends the game in minimum number of moves : -

1)Move the black-square at [1,0] to [0,1]...Now the chessboard looks like this : -

0 1 0

0 0 1

0 0 0

2) We move the black-square at [1,2] to [0,1] and the chessboard looks like this:-

0 1 0

0 0 0

0 0 0

Now, there are no valid moves left and the game ends :-)

Given a chessboard of size 'N' x 'N' and any configuration of black and white-squares, how to find the sequence of moves which ends the game in minimum number of moves ?

## closed as off-topic by Jaap Scherphuis, Joshua Mundinger, Robert Shore, Lee David Chung Lin, LeucippusMay 10 at 2:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – Jaap Scherphuis, Joshua Mundinger, Robert Shore, Leucippus
If this question can be reworded to fit the rules in the help center, please edit the question.

## locked by Alexander Gruber♦May 10 at 4:52

This question is locked in view of our policy about contest questions. Questions originating from active contests are locked for the duration of the contest, with answers hidden from view by soft-deletion. Please see the comments below for references to the originating contest.

• This seems to be one of the questions on the current codechef contest. – Jaap Scherphuis May 9 at 8:46
• It is a violation of the rules of this site to post problems from current contests. – saulspatz May 9 at 8:50
• I don't think my question matches with any ongoing contest , it was asked to me by a fried and I can't see any similarity, stop the blaming when there is no similarity, in this way, I CAN SAY THAT EVERY QUESTION IS SIMILAR TO SOME OTHER QUESTION :( – Guhfg gehlthon May 9 at 9:31
• If you follow the link I gave in my previous comment, you will see that it is the same, except that it uses pawns instead of black squares. Tell your friend not to cheat. – Jaap Scherphuis May 9 at 9:50
• @saulspatz where is this rule published? – גלעד ברקן May 9 at 11:34