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

Home > Just Math
Array Assignment (Posted on 2014-05-20) Difficulty: 3 of 5
A 4x4 array with entries from the set {0,1,2,3} is such that:
  • The sum of each of the four rows is divisible by 4, and:
  • The sum of each of the four columns is divisible by 4
Determine the total number of arrays having the above property.

Notes:

(i) Two or more cells of a given row or column may or may not contain the same number.
(ii) Disregard rotations or reflections.

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Taking into consideration (ii) Comment 2 of 2 |
DefDbl A-Z
Dim crlf$, a(4, 4), solct, bd(8)


Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 fillIn 1, 1
  
 Text1.Text = Text1.Text + Str(solct) + crlf$
 For i = 1 To 8
  Text1.Text = Text1.Text + Str(bd(i))
 Next
 Text1.Text = Text1.Text + crlf
 
End Sub

Sub fillIn(row, col)
  If row < 4 And col < 4 Then
    For v = 0 To 3
      a(row, col) = v
      c = col + 1
      If c = 4 Then
        v4 = (16 - a(row, 1) - a(row, 2) - a(row, 3)) Mod 4
        a(row, 4) = v4
        fillIn row + 1, 1
      Else
        fillIn row, c
      End If
    Next
  Else
    v4 = (16 - a(1, col) - a(2, col) - a(3, col)) Mod 4
    a(row, col) = v4
    If col = 4 Then
      If (a(1, 4) + a(2, 4) + a(3, 4) + a(4, 4)) Mod 4 = 0 Then
        vct = 0
        For revr = -1 To 1 Step 2
        For revc = -1 To 1 Step 2
          good1 = 1: good2 = 1
          For r = 1 To 4
          For c = 1 To 4
            compr = r * revr: If compr < 0 Then compr = compr + 5
            compc = c * revc: If compc < 0 Then compc = compc + 5
            If a(r, c) <> a(compr, compc) Then good1 = 0
            If a(r, c) <> a(compc, compr) Then good2 = 0
          Next
          Next
          vct = vct + good1 + good2
        Next
        Next
      
      
        solct = solct + 1 * vct / 8
        bd(vct) = bd(vct) + 1
        If bd(vct) < 10 Then
         For r = 1 To 4
         For c = 1 To 4
           Text1.Text = Text1.Text & a(r, c)
         Next: Text1.Text = Text1.Text & crlf$
         Next: Text1.Text = Text1.Text & Str(vct) & crlf$
         DoEvents
        End If
      End If
    Else
      fillIn row, col + 1
    End If
  End If
End Sub

finds the following, where the first nine with each given number of symmetries are shown, to verify the symmetry count is correct. The degree of symmetry is shown below each tableau:

0000
0000
0000
0000
 8
0000
0000
0013
0031
 2
0000
0000
0022
0022
 2
0000
0000
0031
0013
 2
0000
0000
0103
0301
 1
0000
0000
0112
0332
 1
0000
0000
0121
0323
 1
0000
0000
0130
0310
 1
0000
0000
0202
0202
 1
0000
0000
0211
0233
 1
0000
0000
0220
0220
 2
0000
0000
0233
0211
 1
0000
0000
0301
0103
 1
0000
0000
0310
0130
 1
0000
0000
1111
3333
 2
0000
0000
1300
3100
 2
0000
0000
1331
3113
 2
0000
0000
2002
2002
 2
0000
0000
2200
2200
 2
0000
0130
0310
0000
 4
0000
0220
0220
0000
 8
0000
0310
0130
0000
 4
0000
2002
2002
0000
 4
0000
2222
2222
0000
 4
0013
0031
1300
3100
 4
0013
0121
1210
3100
 4
0013
0211
1120
3100
 4
0013
0301
1030
3100
 4
0022
0022
2200
2200
 4
0220
2002
2002
0220
 8
0220
2222
2222
0220
 8
1111
1111
1111
1111
 8
1111
1331
1331
1111
 8
1331
3113
3113
1331
 8
1331
3333
3333
1331
 8
2002
0000
0000
2002
 8
 
Discounting rotations and reflections, the solution count is 34056.
 
The breakdown is:
 
252480 of all solutions are not symmetric and thus need to be divided by 8 for 31560 unique solutions as each is actually represented 8 times overall, in various rotations and reflections.
 
9376 have twofold symmetry and therefore need to be divided by 4 for 2344 unique solutions
 
272 have fourfold symmetry and need division by 2 for 136 unique solutions.
 
16 have eightfold symmetry and count fully as unique solutions.


  Posted by Charlie on 2014-05-20 15:46:25
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 (19)
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