Here's a simple solution to the Level1, Easy TopCoder Challenge.

- Kim Dam Petersen, email: kimdam@petersen.mail.dk

-- The solution goes here...

/*
* Created on 13-07-2004
*
* Topcoder Challenge: RedSquare.
*/
package challenge;

/**
* <p>RedSquare counts the number of free red squares on a checker
* board with a black square on (1,maxFile).</p>
*
* @author Kim Dam Petersen
*/
public class RedSquare
{
/** Count number of free red squares.
*
* @param maxRank vertical size.
* @param maxFile horizontal size.
* @param rank 1-based vertical position of pieces.
* @param file 1-based horizontal position of pieces.
* @return
*/
public int countTheEmptyReds(int maxRank, int maxFile, int[] rank, int[] file) {
int blackOddity = (1 + maxFile) & 1;
int redCount = (maxRank * maxFile) / 2;

for (int i= 0; i<rank.length; i++) {
int pieceOddity = (rank[i] + file[i]) & 1;
if (pieceOddity != blackOddity) {
redCount--;
}
}
return redCount;
}
}