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

Home > Numbers
Double the Magic (Posted on 2009-10-16) Difficulty: 3 of 5
In the traditional 3 x 3 Magic Square the digital sum ("magic" constant) is 15. The square may be duplicated such that each cell has two identical digits forming a
T U combination (eg 11,22) with the common value being 165 .

The digits 1 to 9 may be placed in each cell so that each Tens digit and each Units digit is represented once in the 3 x 3 grid with no digit reappearing in the same column or row; the column and row totals are to have the same value.

While I can offer a solution with all sums but one major diagonal having the same "magic" constant, can you do similar, or even better, offer 8 equal digital sums?

See The Solution Submitted by brianjn    
No Rating

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

Dim tens(3, 3), units(3, 3), goal
Dim usedT(9), usedU(9)

Private Sub Form_Load()

Me.Visible = True

place 1, 1


End Sub

Sub place(row, col)
 For t = 1 To 9
  DoEvents
  If usedT(t) = 0 Then
   goodT = 1
   For r = 1 To row - 1
     If tens(r, col) = t Then goodT = 0: Exit For
     If units(r, col) = t Then goodT = 0: Exit For
   Next r
   For c = 1 To col - 1
     If tens(row, c) = t Then goodT = 0: Exit For
     If units(row, c) = t Then goodT = 0: Exit For
   Next c
   tens(row, col) = t
          If col = 3 And row = 1 Then
           If tens(1, 3) < tens(1, 1) Then goodT = 0
          End If
          If col = 1 And row = 3 Then
           If tens(3, 1) < tens(1, 1) Or tens(3, 1) < tens(1, 3) Then goodT = 0
          End If
          If col = 3 And row = 3 Then
           If tens(3, 3) < tens(1, 1) Then goodT = 0
          End If

   If goodT Then
     usedT(t) = 1

     For u = 1 To 9
      If usedU(u) = 0 Then
        goodU = 1
        For r = 1 To row - 1
          If tens(r, col) = u Then goodU = 0: Exit For
          If units(r, col) = u Then goodU = 0: Exit For
        Next r
        For c = 1 To col - 1
          If tens(row, c) = u Then goodU = 0: Exit For
          If units(row, c) = u Then goodU = 0: Exit For
        Next c
        If tens(row, col) = u Then goodU = 0
        If goodU Then
          usedU(u) = 1
          units(row, col) = u

          If col = 3 Then
            Select Case row
              Case 1
               CurrentX = 1: CurrentY = 1
               Print tens(1, 1); units(1, 1), tens(1, 2); units(1, 2), tens(1, 3); units(1, 3)
               goal = 10 * (tens(1, 1) + tens(1, 2) + tens(1, 3))
               goal = goal + units(1, 1) + units(1, 2) + units(1, 3)
              Case 2
               g = 10 * (tens(1, 1) + tens(1, 2) + tens(1, 3))
               g = g + units(1, 1) + units(1, 2) + units(1, 3)
               If g <> goal Then goodU = 0
              Case 3
               g = 10 * (tens(1, 1) + tens(1, 2) + tens(1, 3))
               g = g + units(1, 1) + units(1, 2) + units(1, 3)
               If g <> goal Then goodU = 0
               If tens(3, 3) < tens(1, 1) Then goodU = 0
               For c = 1 To 3
                 If goodU Then
                   g = 10 * (tens(1, c) + tens(2, c) + tens(3, c))
                   g = g + units(1, c) + units(2, c) + units(3, c)
                   If g <> goal Then goodU = 0: Exit For
                 End If
               Next
            End Select
          End If
          If goodU Then
            If row = 3 And col = 3 Then
             Open "double magic 2.txt" For Append As #2
             For r = 1 To 3
              For c = 1 To 3
               Print tens(r, c); units(r, c),
               Print #2, tens(r, c); units(r, c),
              Next
              Print: Print #2,
             Next
             ttl1 = 10 * (tens(1, 1) + tens(2, 2) + tens(3, 3))
             ttl1 = ttl1 + units(1, 1) + units(2, 2) + units(3, 3)
             ttl2 = 10 * (tens(3, 1) + tens(2, 2) + tens(1, 3))
             ttl2 = ttl2 + units(3, 1) + units(2, 2) + units(1, 3)
             Print goal; ttl1; ttl2: Print
             Print #2, goal; ttl1; ttl2: Print #2,
             Close 2
            Else
              r = row: c = col
              c = c + 1: If c > 3 Then c = 1: r = r + 1
              place r, c
            End If
          End If

          usedU(u) = 0
        End If
      End If
     Next u

     usedT(t) = 0
   End If
  End If
 Next t
End Sub


finds 168 sets where the sums of all the rows and columns are the same, and in fact 165.  In no instance do both diagonals come out to 165. The number 168 does not include reflections and rotations, as the program requires that the top left number be the least (by checking its tens position), and that the top right number  be lower than the bottom left.

A summary of the 168 such arrays shows 1) the common column or row total, 2) the major diagonal 3) the minor diagonal (i.e., top-right to bottom-left).

 165  120  259
 165  135  264
 165  70  208
 165  85  213
 165  66  192
 165  81  202
 165  116  191
 165  131  201
 165  66  168
 165  108  170
 165  86  183
 165  128  185
 165  73  148
 165  115  150
 165  93  163
 165  135  165
 165  84  214
 165  138  264
 165  74  210
 165  128  260
 165  66  195
 165  120  199
 165  76  201
 165  130  205
 165  66  162
 165  93  182
 165  106  160
 165  133  180
 165  71  147
 165  98  167
 165  111  145
 165  138  165
 165  71  201
 165  122  251
 165  81  196
 165  132  246
 165  85  213
 165  136  214
 165  75  198
 165  126  199
 165  95  192
 165  137  194
 165  75  165
 165  117  167
 165  90  172
 165  132  174
 165  70  145
 165  112  147
 165  132  255
 165  126  259
 165  82  201
 165  76  205
 165  84  198
 165  90  208
 165  134  194
 165  140  204
 165  84  165
 165  99  185
 165  124  163
 165  139  183
 165  77  138
 165  92  158
 165  117  136
 165  132  156
 165  138  260
 165  162  264
 165  68  188
 165  92  192
 165  136  193
 165  160  213
 165  66  138
 165  117  139
 165  106  174
 165  157  175
 165  71  128
 165  122  129
 165  111  164
 165  162  165
 165  93  194
 165  168  264
 165  73  192
 165  148  262
 165  141  197
 165  161  215
 165  66  135
 165  114  175
 165  116  131
 165  164  171
 165  70  129
 165  118  169
 165  120  125
 165  168  165
 165  73  180
 165  145  250
 165  93  176
 165  165  246
 165  167  224
 165  147  200
 165  115  180
 165  169  184
 165  75  132
 165  129  136
 165  111  170
 165  165  174
 165  71  122
 165  125  126
 165  165  255
 165  147  257
 165  95  180
 165  77  182
 165  154  193
 165  172  213
 165  84  132
 165  120  172
 165  134  131
 165  170  171
 165  79  117
 165  115  157
 165  129  116
 165  165  156
 165  192  264
 165  112  180
 165  146  164
 165  191  204
 165  138  137
 165  188  185
 165  142  117
 165  192  165
 165  111  184
 165  195  264
 165  150  166
 165  190  205
 165  136  133
 165  193  183
 165  138  115
 165  195  165
 165  114  166
 165  198  246
 165  199  214
 165  159  169
 165  200  194
 165  150  137
 165  198  174
 165  148  117
 165  198  255
 165  118  171
 165  164  161
 165  203  201
 165  154  130
 165  202  180
 165  150  106
 165  198  156
 165  158  237
 165  182  257
 165  183  262
 165  163  238
 165  170  237
 165  188  257
 165  169  235
 165  189  253
 165  160  216
 165  205  256
 165  201  263
 165  161  218
 165  169  219
 165  208  259
 165  170  212
 165  210  251

Note the following cases (among others) where there is a diagonal with the 165 total, and another that is close:

  165  165  156
  165  168  165
  165  162  165
 
They are:
 28   96   41         
 74   52   39        
 63   17   85        
 
 (165  165  156)
 
 
 23   97   45        
 78   56   31       
 64   12   89       
 
 (165  168  165)
 
 21   98   46        
 79   54   32        
 65   13   87
 
 (165  162  165)
 
 

  Posted by Charlie on 2009-10-16 18:59:07
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 (8)
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