All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
3x3 sums (Posted on 2004-05-15) Difficulty: 3 of 5
Fill a 3 by 3 grid with the digits 1 to 9 using the following five rules:

1. The sum of the top row is twice the sum of the center row.

2. The sum of the left column is twice the sum of the center column.

3. The sum of the right column plus twice the sum of the bottom row is equal to the sum of the whole grid.

4. The sum of the bottom row plus twice the sum of the right column is not equal to the sum of the whole grid.

5. The top row is the only row with both odd and even numbers.

Show that there is only one solution.

See The Solution Submitted by Axorion    
Rating: 3.0000 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re: Solution | Comment 2 of 11 |
(In reply to Solution by Penny)

While Visual Basic is great for making GUI applications, and it is good programming practice to declare all your variables, sometimes this can be a hindrance to an easy understanding of the programs.  I think QuickBasic comes closer to what I think someone has asked for: pseudocode.  And in DOS, the following QB program goes through all the possibilities in less than 4/10 of a second:

timeStart = TIMER
FOR d = 1 TO 9
 FOR e = 1 TO 9
  IF e <> d THEN
   FOR f = 1 TO 9
    IF f <> d AND f <> e THEN
     t = d MOD 2 + e MOD 2 + f MOD 2
     IF t = 0 OR t = 3 THEN
   FOR g = 1 TO 9
    IF g <> d AND g <> e AND g <> f THEN
     FOR h = 1 TO 9
      IF h <> d AND h <> e AND h <> f AND h <> g THEN
       FOR i = 1 TO 9
        IF i <> d AND i <> e AND i <> f AND i <> g AND i <> h THEN
         t = g MOD 2 + h MOD 2 + i MOD 2
         IF t = 0 OR t = 3 THEN
       FOR a = 1 TO 9
         IF a <> d AND a <> e AND a <> f AND a <> g AND a <> h AND a <> i THEN
          FOR b = 1 TO 9
           IF b <> d AND b <> e AND b <> f AND b <> g AND b <> h AND b <> i AND b <> a THEN
            c = 45 - a - b - d - e - f - g - h - i
            IF a + b + c = 2 * (d + e + f) THEN
             IF a + d + g = 2 * (b + e + h) THEN
              IF c + f + i + 2 * (g + h + i) = 45 THEN
               PRINT a, b, c
               PRINT d, e, f
               PRINT g, h, i
              END IF
             END IF
            END IF
           END IF
          NEXT b
         END IF
       NEXT a
         END IF
        END IF
       NEXT i
      END IF
     NEXT h
    END IF
   NEXT g
     END IF
    END IF
   NEXT f
  END IF
 NEXT e
NEXT d
PRINT TIMER - timeStart

The results being:

 9             5             8
 3             1             7
 4             2             6
 .390625

the decimal fraction being the clock execution time in seconds.


  Posted by Charlie on 2004-05-15 15:47:09
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (24)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information