Arrange 9 consecutive integers in 9 squares so that the sum of the integers in each row, in each column, and in each of the two diagonals is 2007.

2. Originally Posted by ggw
Arrange 9 consecutive integers in 9 squares so that the sum of the integers in each row, in each column, and in each of the two diagonals is 2007.
Here's the solution:

Code:
|-----|-----|-----|
| 666 | 671 | 670 |
|-----|-----|-----|
| 673 | 669 | 665 |
|-----|-----|-----|
| 668 | 667 | 672 |
|-----|-----|-----|
Would you like an explanation?

3. Nice work, Quick!

Here's my explanation.

First construct a 3-by-3 magic square with the numbers 1 to 9.
Since the sum of all nine numbers is 45,
. . the sum of any row or column will be 15.

We have the numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9.

The secret is to place the middle number in the center cell.
Code:
      * - * - * - *
|   |   |   |
* - * - * - *
|   | 5 |   |
* - * - * - *
|   |   |   |
* - * - * - *

Then place numbers in pairs which add up to 10:
. . (1,9), (2,8), (3,7), (4,6)

Place (4,6) on a diagonal.
Code:
      * - * - * - *
|   |   | 6 |
* - * - * - *
|   | 5 |   |
* - * - * - *
| 4 |   |   |
* - * - * - *

Where can be place the "9"?
It cannot go in the top row (it makes the total 15 already).
It cannot go in the right column (same reason).
There are two choices for placing the "9".
. . Take the first cell in the second row.
. . This forces "1" to be on the far right.
Code:
      * - * - * - *
|   |   | 6 |
* - * - * - *
| 9 | 5 | 1 |
* - * - * - *
| 4 |   |   |
* - * - * - *

And the remaining numbers are "forced".
Code:
      * - * - * - *
| 2 | 7 | 6 |
* - * - * - *
| 9 | 5 | 1 |
* - * - * - *
| 4 | 3 | 8 |
* - * - * - *

Now add 664 to each number:
Code:
      * - - * - - * - - *
| 666 | 671 | 670 |
* - - * - - * - - *
| 673 | 669 | 665 |
* - - * - - * - - *
| 668 | 667 | 672 |
* - - * - - * - - *

and we have Quick's solution!