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

Home > Probability
3x3 Grid Near Magic (Posted on 2009-12-05) Difficulty: 2 of 5
N is a 3x3 square grid which is constituted by using each of the digits from 1 to 9 exactly once.

Determine the probability that the first digit minus the second digit plus the third digit in each row (reading left to right), each column (reading top to bottom), and each main diagonal (reading top to bottom) of N is the same.

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
computer solution | Comment 1 of 6

using qbasic I found the following 8 solutions

Solution # 1: constant=  5
 2  1  4
 3  5  7
 6  9  8
+++++++++++++
Solution # 2: constant=  5
 2  3  6
 1  5  9
 4  7  8
+++++++++++++
Solution # 3: constant=  5
 4  1  2
 7  5  3
 8  9  6
+++++++++++++
Solution # 4: constant=  5
 4  7  8
 1  5  9
 2  3  6
+++++++++++++
Solution # 5: constant=  5
 6  3  2
 9  5  1
 8  7  4
+++++++++++++
Solution # 6: constant=  5
 6  9  8
 3  5  7
 2  1  4
+++++++++++++
Solution # 7: constant=  5
 8  7  4
 9  5  1
 6  3  2
+++++++++++++
Solution # 8: constant=  5
 8  9  6
 7  5  3
 4  1  2

and since there are 9!=362880 possible grids then then
the probability is 8/9!=1/45360=0.0000220459

the solutions were generated with the following code
OPEN "output.txt" FOR OUTPUT AS #1
CLS 0
cnt = 0
FOR g1 = 1 TO 9
 FOR g2 = 1 TO 9
  IF g2 <> g1 THEN
   FOR g3 = 1 TO 9
    IF g3 <> g1 AND g3 <> g2 THEN
     c = g1 - g2 + g3
     FOR g4 = 1 TO 9
      IF g4 <> g1 AND g4 <> g2 AND g4 <> g3 THEN
       FOR g5 = 1 TO 9
        IF g5 <> g1 AND g5 <> g2 AND g5 <> g3 AND g5 <> g4 THEN
         FOR g6 = 1 TO 9
          IF g6 <> g1 AND g6 <> g2 AND g6 <> g3 AND g6 <> g4 AND g6 <> g5 THEN
           FOR g7 = 1 TO 9
            IF g7 <> g1 AND g7 <> g2 AND g7 <> g3 AND g7 <> g4 AND g7 <> g5 AND g7 <> g6 THEN
             FOR g8 = 1 TO 9
              IF g8 <> g1 AND g8 <> g2 AND g8 <> g3 AND g8 <> g4 AND g8 <> g5 AND g8 <> g6 AND g8 <> g7 THEN
               FOR g9 = 1 TO 9
                IF g9 <> g1 AND g9 <> g2 AND g9 <> g3 AND g9 <> g4 AND g9 <> g5 AND g9 <> g6 AND g9 <> g7 AND g9 <> g8 THEN
                 IF g4 - g5 + g6 = c AND g7 - g8 + g9 = c AND g1 - g4 + g7 = c AND g2 - g5 + g8 = c AND g3 - g6 + g9 = c AND g1 - g5 + g9 = c AND g3 - g5 + g7 = c THEN
                  cnt = cnt + 1
                  PRINT #1, "Solution #" + STR$(cnt) + ": constant= " + STR$(c)
                  PRINT #1, g1; g2; g3
                  PRINT #1, g4; g5; g6
                  PRINT #1, g7; g8; g9
                  PRINT #1, "+++++++++++++"
                 END IF
                END IF
               NEXT g9
              END IF
             NEXT g8
            END IF
           NEXT g7
          END IF
         NEXT g6
        END IF
       NEXT g5
      END IF
     NEXT g4
    END IF
   NEXT g3
  END IF
 NEXT g2
NEXT g1
CLOSE #1


 


  Posted by Daniel on 2009-12-05 13:12:45
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 (1)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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