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

Home > Just Math
Magic matrix (Posted on 2015-10-26) Difficulty: 2 of 5
The 1 to 9 digits are randomly arranged into a 3x3 array.

Find the probability that the sum of the numbers in every row, column, and diagonal is a multiple of 9.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 1 of 1
72 out of the 362880 permutations of the nine digits satisfy the criteria for a probability of 1/5040 ~= 0.000198412698412698.

Filtering out rotations and reflections by requiring the top-left number to be the smallest corner and the top-right number to be smaller than the bottom-left number, the following are the nine basic ways the criteria can be met:

126
837
945

153
297
648

153
864
972

216
738
954

243
198
657

315
864
729

324
198
576

324
765
819

657
432
819

DefDbl A-Z
Dim crlf$, dig(9)


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)

 d$ = "123456789": h$ = d$
 Do
   DoEvents
   For i = 1 To Len(d)
     dig(i) = Val(Mid(d, i, 1))
   Next
   good = 1
   For maj = 0 To 6 Step 3
     tot = 0
     For mnr = 1 To 3
       tot = tot + dig(maj + mnr)
     Next
     If tot Mod 9 <> 0 Then good = 0: Exit For
   Next
   If good Then
     For maj = 1 To 3
       tot = 0
       For mnr = 0 To 6 Step 3
         tot = tot + dig(maj + mnr)
       Next
       If tot Mod 9 <> 0 Then good = 0: Exit For
     Next
     If good Then
       tot1 = dig(1) + dig(5) + dig(9)
       tot2 = dig(3) + dig(5) + dig(7)
       If tot1 Mod 9 = 0 And tot2 Mod 9 = 0 Then
         If dig(1) < dig(3) And dig(3) < dig(7) And dig(1) < dig(9) Then
          Text1.Text = Text1.Text & Mid(d, 1, 3) & crlf
          Text1.Text = Text1.Text & Mid(d, 4, 3) & crlf
          Text1.Text = Text1.Text & Mid(d, 7, 3) & crlf
          Text1.Text = Text1.Text & crlf
         End If
         ct = ct + 1
       End If
     End If
   End If
   
   overct = overct + 1
   
   permute d
 Loop Until d = h
 

 Text1.Text = Text1.Text & ct & Str(overct) & Str(ct / overct) & crlf & " done"
  
End Sub


  Posted by Charlie on 2015-10-26 10:55:37
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 (7)
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