"?." ".O" |
If the question mark is set to '.', then:
Example | Board | Answer |
0 | "?." ".O" |
5 |
0 | "???" "?O?" "???" |
1952 |
0 | "...?." "?...." ".O..." "..?.." "....?" |
221 |
0 | "OOOOOOOOOOOOOOOOOOOOO" |
21 |
0 | "?????????OO??????????" |
9963008 |
0 | "OOO" "O?O" "OOO" "..." |
18 |
Of course, what you do during each iteration has to be relatively fast, too.
Here's the outline of the solution:
Let's use Example 2 to illustrate. In this example, you have:
Subset | Subset in hex | The board | Min row | Max row | Min col | Max col | Rectangle Size | Final Sum |
{ } | 0x0 | ..... ..... .O... ..... ..... |
2 | 2 | 1 | 1 | 1 | 1 |
{ 0 } | 0x1 | ...X. ..... .O... ..... ..... |
0 | 2 | 1 | 3 | 9 | 10 |
{ 1 } | 0x2 | ..... X.... .O... ..... ..... |
1 | 2 | 0 | 1 | 4 | 14 |
{ 0 1 } | 0x3 | ...X. X.... .O... ..... ..... |
0 | 2 | 0 | 3 | 12 | 26 |
{ 2 } | 0x4 | ..... ..... .O... ..X.. ..... |
2 | 3 | 1 | 2 | 4 | 30 |
{ 0 2 } | 0x5 | ...X. ..... .O... ..X.. ..... |
0 | 3 | 1 | 3 | 12 | 42 |
{ 1 2 } | 0x6 | ..... X.... .O... ..X.. ..... |
1 | 3 | 0 | 2 | 9 | 51 |
{ 0 1 2 } | 0x7 | ...X. X.... .O... ..X.. ..... |
0 | 3 | 0 | 3 | 16 | 67 |
{ 3 } | 0x8 | ..... ..... .O... ..... ....X |
2 | 4 | 1 | 4 | 12 | 79 |
{ 0 3 } | 0x9 | ...X. ..... .O... ..... ....X |
0 | 4 | 1 | 4 | 20 | 99 |
{ 1 3 } | 0xa | ..... X.... .O... ..... ....X |
1 | 4 | 0 | 4 | 20 | 119 |
{ 0 1 3 } | 0xb | ...X. X.... .O... ..... ....X |
0 | 4 | 0 | 4 | 25 | 144 |
{ 2 3 } | 0xc | ..... ..... .O... ..X.. ....X |
2 | 4 | 1 | 4 | 12 | 156 |
{ 0 2 3 } | 0xd | ...X. ..... .O... ..X.. ....X |
0 | 4 | 1 | 4 | 20 | 176 |
{ 1 2 3 } | 0xe | ..... X.... .O... ..X.. ....X |
1 | 4 | 0 | 4 | 20 | 196 |
{ 0 1 2 3 } | 0xf | ...X. X.... .O... ..X.. ....X |
0 | 4 | 0 | 4 | 25 | 221 |