Vorige Pagina About the Author

' Search for Bimagic Squares of Subtraction

' Tested with Office 365 under Windows 10

Sub TestSqrs8()

Dim a(64), b(8), Res8(18)

y = MsgBox("Blocked", vbExclamation, "TestSqrs88")
End

k1 = 1: k2 = 1

Sheets("Klad1").Select

For j100 = 1 To 136244

'   Read Bimagic Square (8 x 8)

    For i1 = 1 To 64
        a(i1) = Sheets("Bimagic8").Cells(j100, i1).Value
    Next i1
    
'   Determine Residu's
    
    For i10 = 1 To 18
    
        GoSub 1000  'Determine Residu per Line
        
'       Check residu's are Identical
        
        If i10 >= 2 Then
           If Res8(i10) <> Res8(i10 - 1) Then GoTo 5
        End If
   
    Next i10

    n9 = n9 + 1: GoSub 650        'Print results (squares)

5

Next j100

End

'   Determine Residuum line i10

1000

    Select Case i10
    
'       Rows
    
        Case 1:
                b(1) = a(1): b(2) = a(2): b(3) = a(3): b(4) = a(4): b(5) = a(5): b(6) = a(6): b(7) = a(7): b(8) = a(8):
                GoSub 1200
        Case 2:
                b(1) = a(9): b(2) = a(10): b(3) = a(11): b(4) = a(12): b(5) = a(13): b(6) = a(14): b(7) = a(15): b(8) = a(16):
                GoSub 1200
        Case 3:
                b(1) = a(17): b(2) = a(18): b(3) = a(19): b(4) = a(20): b(5) = a(21): b(6) = a(22): b(7) = a(23): b(8) = a(24):
                GoSub 1200
        Case 4:
                b(1) = a(25): b(2) = a(26): b(3) = a(27): b(4) = a(28): b(5) = a(29): b(6) = a(30): b(7) = a(31): b(8) = a(32):
                GoSub 1200
        Case 5:
                b(1) = a(33): b(2) = a(34): b(3) = a(35): b(4) = a(36): b(5) = a(37): b(6) = a(38): b(7) = a(39): b(8) = a(40):
                GoSub 1200
        Case 6:
                b(1) = a(41): b(2) = a(42): b(3) = a(43): b(4) = a(44): b(5) = a(45): b(6) = a(46): b(7) = a(47): b(8) = a(48):
                GoSub 1200
        Case 7:
                b(1) = a(49): b(2) = a(50): b(3) = a(51): b(4) = a(52): b(5) = a(53): b(6) = a(54): b(7) = a(55): b(8) = a(56):
                GoSub 1200
        Case 8:
                b(1) = a(57): b(2) = a(58): b(3) = a(59): b(4) = a(60): b(5) = a(61): b(6) = a(62): b(7) = a(63): b(8) = a(64):
                GoSub 1200

'       Columns
                                                        
        Case 9:
                b(1) = a(1): b(2) = a(9): b(3) = a(17): b(4) = a(25): b(5) = a(33): b(6) = a(41): b(7) = a(49): b(8) = a(57):
                GoSub 1200
        Case 10:
                b(1) = a(2): b(2) = a(10): b(3) = a(18): b(4) = a(26): b(5) = a(34): b(6) = a(42): b(7) = a(50): b(8) = a(58):
                GoSub 1200
        Case 11:
                b(1) = a(3): b(2) = a(11): b(3) = a(19): b(4) = a(27): b(5) = a(35): b(6) = a(43): b(7) = a(51): b(8) = a(59):
                GoSub 1200
        Case 12:
                b(1) = a(4): b(2) = a(12): b(3) = a(20): b(4) = a(28): b(5) = a(36): b(6) = a(44): b(7) = a(52): b(8) = a(60):
                GoSub 1200
        Case 13:
                b(1) = a(5): b(2) = a(13): b(3) = a(21): b(4) = a(29): b(5) = a(37): b(6) = a(45): b(7) = a(53): b(8) = a(61):
                GoSub 1200
        Case 14:
                b(1) = a(6): b(2) = a(14): b(3) = a(22): b(4) = a(30): b(5) = a(38): b(6) = a(46): b(7) = a(54): b(8) = a(62):
                GoSub 1200
        Case 15:
                b(1) = a(7): b(2) = a(15): b(3) = a(23): b(4) = a(31): b(5) = a(39): b(6) = a(47): b(7) = a(55): b(8) = a(63):
                GoSub 1200
        Case 16:
                b(1) = a(8): b(2) = a(16): b(3) = a(24): b(4) = a(32): b(5) = a(40): b(6) = a(48): b(7) = a(56): b(8) = a(64):
                GoSub 1200
                                                        
'       Diagonals
                                                        
        Case 17:
                b(1) = a(1): b(2) = a(10): b(3) = a(19): b(4) = a(28): b(5) = a(37): b(6) = a(46): b(7) = a(55): b(8) = a(64):
                GoSub 1200
        Case 18:
                b(1) = a(8): b(2) = a(15): b(3) = a(22): b(4) = a(29): b(5) = a(36): b(6) = a(43): b(7) = a(50): b(8) = a(57):
                GoSub 1200
    
    End Select

    Return

1200

    For i2 = 1 To 7
    For i1 = i2 To 8
        If b(i2) < b(i1) Then
            x = b(i1)
            b(i1) = b(i2)
            b(i2) = x
        End If
    Next i1
    Next i2

    Res8(i10) = b(1) - b(2) + b(3) - b(4) + b(5) - b(6) + b(7) - b(8)

    Return

'   Print results (squares)

650 n2 = n2 + 1
    If n2 = 5 Then
        n2 = 1: k1 = k1 + 9: k2 = 1
    Else
        If n9 > 1 Then k2 = k2 + 9
    End If

    Cells(k1, k2 + 1).Font.Color = -4165632
    Cells(k1, k2 + 1).Value = j100
    Cells(k1, k2 + 2).Value = Res8(1)
    
    i3 = 0
    For i1 = 1 To 8
        For i2 = 1 To 8
            i3 = i3 + 1
            Cells(k1 + i1, k2 + i2).Value = a(i3)
        Next i2
    Next i1

    Return

End Sub

Vorige Pagina About the Author