# Can you solve it?

How many rectangles on a chessboard?

And for you smart people, how many of those rectangles have more white squares than dark squares?

I assume you see a square as a rectangle too?

If not, the answer to the 2nd question will be x/2, if the answer to the 1st is x.

I make it 1429 rectangles, of which 586 have more white squares :)

351, thats what i get. But i think i'm not right about it.

All squares are also rectangles. So, including the single squares, we have 1287 rectangles.

Any rectangle will only have differing numbers of light and dark squares if both its side measurements are odd numbers (1x3, 1x5, 1x7, 3x5, 3x7, 5x7, and the squares 1x1, 3x3, 5x5 and 7x7). The total of rectangles with only odd-numbered sides is 400, therefore the number of rectangles with more light than dark squares is 200.

I thought 1429 was not enough, but after some calulations I come with the answer of 1296. The number of those rectangles with more white squares then black is then 200.

LoekBergman is correct. 1296 is the total number of rectangles in a chessboard. But the total number of rectangles with more white than black squares is 236 to be precise. Good ol' advanced mathematics

Any doubts class?

@The_logicalist245: I made a computer program to find it out:

public class SchaakveldenEnRechthoeken {

public static void main(String[] args) {
int c = 0;
List<Integer> oneside = new ArrayList<Integer>();
List<Integer> theOtherside = new ArrayList<Integer>();

int x = 0;
int y = 0;
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
if (j >= i) {
}
}
}
int c2 = 0;
int cOdd = 0;
int prod = 0;
for (int i = 0; i < oneside.size(); i++) {
c2 = 0;
for (int a = 1; a <= 8; a++) {
for (int b = 1; b <= 8; b++) {
x = a + oneside.get(i) - 1;
y = b + theOtherside.get(i) - 1;
if (x <= 8 && y <= 8) {
c2++;
c++;
}
if (oneside.get(i) != theOtherside.get(i)) {
x = a + theOtherside.get(i) - 1;
y = b + oneside.get(i) - 1;
if (x <= 8 && y <= 8) {
c2++;
c++;
}
}
}
}
System.out.println("Number of different rectangles for " + oneside.get(i) + ", " + theOtherside.get(i) + ": " + c2);
prod = oneside.get(i) * theOtherside.get(i);
if(prod%2 == 1){
cOdd = cOdd + c2/2;
}

}
//               c++;
System.out.println("Total number of different rectangles: " + c);
System.out.println("Number of rectangles with more white squares then black ones: " + cOdd);
}
}

run:
Number of different rectangles for 1, 1: 64
Number of different rectangles for 1, 2: 112
Number of different rectangles for 1, 3: 96
Number of different rectangles for 1, 4: 80
Number of different rectangles for 1, 5: 64
Number of different rectangles for 1, 6: 48
Number of different rectangles for 1, 7: 32
Number of different rectangles for 1, 8: 16
Number of different rectangles for 2, 2: 49
Number of different rectangles for 2, 3: 84
Number of different rectangles for 2, 4: 70
Number of different rectangles for 2, 5: 56
Number of different rectangles for 2, 6: 42
Number of different rectangles for 2, 7: 28
Number of different rectangles for 2, 8: 14
Number of different rectangles for 3, 3: 36
Number of different rectangles for 3, 4: 60
Number of different rectangles for 3, 5: 48
Number of different rectangles for 3, 6: 36
Number of different rectangles for 3, 7: 24
Number of different rectangles for 3, 8: 12
Number of different rectangles for 4, 4: 25
Number of different rectangles for 4, 5: 40
Number of different rectangles for 4, 6: 30
Number of different rectangles for 4, 7: 20
Number of different rectangles for 4, 8: 10
Number of different rectangles for 5, 5: 16
Number of different rectangles for 5, 6: 24
Number of different rectangles for 5, 7: 16
Number of different rectangles for 5, 8: 8
Number of different rectangles for 6, 6: 9
Number of different rectangles for 6, 7: 12
Number of different rectangles for 6, 8: 6
Number of different rectangles for 7, 7: 4
Number of different rectangles for 7, 8: 4
Number of different rectangles for 8, 8: 1
Total number of different rectangles: 1296
Number of rectangles with more white squares then black ones: 200
BUILD SUCCESSFUL (total time: 1 second)

Could you tell me how you arrived at the number of 236?

God, how I hate C++. Cryptography is actually my forte.

Uhh.. Since I calculated it on paper, inaccuracies are bound to happen. And I just found my mistake... Glad to know that I'm human. Thanks for the welcome reminder LoekBergman. The answer's 200.

Your welcome, and for your further relieve: I wrote the program in Java.

Hahaha... silly me!

Either way... good programming. I still prefer to do calculations by myself though.. There's nothing better than good manual labour. Sets things right. So now do we have to live an aimless life, or do you have another question? Preferrably one related to chess?

Yes, indeed, it is 1296/200. CapnPugwash, I'm interested to see how you got the 200 correct but missed 9 of the total rectangles. Sometimes these errors have a way of propagating.

Thanks to BayAreaChess for the puzzle. Personally I did it by hand but was suspicious of the nice round numbers (400, 200), so wrote a small Python script to solve/verify.

Thanks. I was looking for the proper set of formulas as well, but could not find it. Then I thought using my current knowledge would be faster.

Anyhow, I do make mistakes as well. Can you find what my opponent did? I did not foresee it.

Can you solve it?

Ozzie - that must have been a simple addition mistake; I did it all by hand. There are simple patterns - 112 2x1, 96 3x1, 80 4x1 and so on. And the number of squares with side length x is (9-x)² - maybe I forgot the 9 6x6 squares.

The 200 was easy once I´d realised that all rectangles with an even number of squares also have an equal number of dark and light, so we were only looking for the rectangles with odd x odd sides.

Anyway, thanks for the puzzle, I enjoyed it!

I am perplexed as to how there could be any light square/dark square difference when constructing and counting rectangles.

ghost - no rectangle with an odd number of squares in it can have equal numbers of both light and dark; take a look for instance at various 3x3 squares on the chessboard, they´ll all have 5/4.

Loek - I´m not sure, but was it something along these lines? (starts on move 20):

Right, so dividing 400 by 2 is the easy part... did you just count the 400 by hand?

@CapnPugwash: You are close to it, but it was not exactly that. I had already given up at move 25.

Well, I cant decipher the computer program, and I'm not like an advanced mathematician or anything. I just added up all the rectangle combinations and tried to figure how many of each can fit onto a board.

I accept my total might be wrong, but I cannot understand how the answer could be an even number. All rectangle combinations fit onto a board an even number of times, except 1 (8x8), so the answer HAS to be odd?

No Ozzie, I just used the lists which I already had. Example:

1x2: 56*2 = 112

I get this figure by imagining a rectangle, 2 wide and 1 high, in the top left hand corner of the board. I can slide it one square to the right 7 times before it will go no further. I can also repeat this process on each of the  7 lower ranks. Total = 7*8 = 56. The rectangle can also be rotated through 90° and will give further 56 possibilities.

Looking at the other rectangles, a pattern emerges:

1x3: 48*2 = 96

1x4: 40*2 = 80

1x5: 32*2 = 64

1x6: 24*2 = 48

1x7: 16*2 = 32

1x8: 8*2 = 16

The total decereases by 16 for each increase in the breadth by 1. So you don´t have to count all the possibilities; you just need the first two, and the rest follows a pattern. For interest - if the height of the rectangles is 2, the totals decrease by 14; if 3, then by 12, and so on.

Sounds complicated maybe, but it isn´t; it took about 5 minutes to get the full list of all possibilities. And when I had that, all I had to do was 1. add them up (fail!) and 2. add up the ones which represented odd-numbered rectangles: 1x1, 1x3, 1x5, 1x7, 3x3, 3x5, 3x7, 5x5, 5x7 and 7x7.

@rooperi - that´s what I also thought at first, but there are 4 squares which fit in an odd number of times: 8x8 (1), 6x6 (9), 4x4 (25) and 2x2 (49).