Vorige Pagina About the Author

' Generates Associated Lozenge Squares of order 11

' Tested with Office 365 under Windows 10

Sub AssBrd11()

    Dim a1(61), a(121), b1(121), b(121), c(121)
 
    y = MsgBox("Locked", vbCritical, "Routine AssBrd11")
    End

    Sheets("Klad1").Select

    n5 = 0: n9 = 0: k1 = 1: k2 = 1
 
    Sheets("Klad1").Select
    
    t1 = Timer

    i2 = 0
    For i1 = 2 To 120 Step 2                                 'Even Numbers
        i2 = i2 + 1
        a1(i2) = i1: b1(a1(i2)) = a1(i2)
    Next i1
    m1 = 1: m2 = 60: s1 = 671: p2 = 122
    s3 = 3 * p2 / 2: s4 = 2 * p2

For j150 = 401 To 600 ''7297                                 'Read Diamond Inlays (Odd Numbers)

    For i1 = 1 To 121
        a(i1) = Sheets("DiaLns56").Cells(j150, i1).Value
    Next i1

t11 = Timer                                                 'Time Out

    For j117 = m1 To m2
    If b(a1(j117)) = 0 Then b(a1(j117)) = a1(j117): c(117) = a1(j117) Else GoTo 1170
    a(117) = a1(j117)

    a(5) = p2 - a(117): If b(a(5)) = 0 Then b(a(5)) = a(5): c(5) = a(5) Else GoTo 50

    a(115) = s1 - a(5) - a(16) - a(27) - a(38) - a(49) - a(60) - a(71) - a(82) - a(93) - a(104)
    If a(115) < a1(m1) Or a(115) > a1(m2) Then GoTo 1150:
    If b1(a(115)) = 0 Then GoTo 1150
    If b(a(115)) = 0 Then b(a(115)) = a(115): c(115) = a(115) Else GoTo 1150
   
    a(7) = p2 - a(115): If b(a(7)) = 0 Then b(a(7)) = a(7): c(7) = a(7) Else GoTo 70

    For j77 = m1 To m2
    If b(a1(j77)) = 0 Then b(a1(j77)) = a1(j77): c(77) = a1(j77) Else GoTo 770
    a(77) = a1(j77)

    a(45) = p2 - a(77): If b(a(45)) = 0 Then b(a(45)) = a(45): c(45) = a(45) Else GoTo 450
    
    a(55) = s1 - a(45) - a(46) - a(47) - a(48) - a(49) - a(50) - a(51) - a(52) - a(53) - a(54)
    If a(55) < a1(m1) Or a(55) > a1(m2) Then GoTo 550:
    If b1(a(55)) = 0 Then GoTo 550
    If b(a(55)) = 0 Then b(a(55)) = a(55): c(55) = a(55) Else GoTo 550
    
    a(67) = p2 - a(55): If b(a(67)) = 0 Then b(a(67)) = a(67): c(67) = a(67) Else GoTo 670
   
    For j121 = m1 To m2
    If b(a1(j121)) = 0 Then b(a1(j121)) = a1(j121): c(121) = a1(j121) Else GoTo 1210
    a(121) = a1(j121)
    
    a(1) = p2 - a(121): If b(a(1)) = 0 Then b(a(1)) = a(1): c(1) = a(1) Else GoTo 10
    
    For j120 = m1 To m2
    If b(a1(j120)) = 0 Then b(a1(j120)) = a1(j120): c(120) = a1(j120) Else GoTo 1200
    a(120) = a1(j120)
    
    a(2) = p2 - a(120): If b(a(2)) = 0 Then b(a(2)) = a(2): c(2) = a(2) Else GoTo 20
    
    For j119 = m1 To m2
    If b(a1(j119)) = 0 Then b(a1(j119)) = a1(j119): c(119) = a1(j119) Else GoTo 1190
    a(119) = a1(j119)
    
    a(3) = p2 - a(119): If b(a(3)) = 0 Then b(a(3)) = a(3): c(3) = a(3) Else GoTo 30
    
    a(118) = s4 - a(119) - a(120) - a(121)
    If a(118) < a1(m1) Or a(118) > a1(m2) Then GoTo 1180:
    If b1(a(118)) = 0 Then GoTo 1180
    If b(a(118)) = 0 Then b(a(118)) = a(118): c(118) = a(118) Else GoTo 1180
    
    a(4) = p2 - a(118): If b(a(4)) = 0 Then b(a(4)) = a(4): c(4) = a(4) Else GoTo 40

    For j114 = m1 To m2
    If b(a1(j114)) = 0 Then b(a1(j114)) = a1(j114): c(114) = a1(j114) Else GoTo 1140
    a(114) = a1(j114)
    
    a(8) = p2 - a(114): If b(a(8)) = 0 Then b(a(8)) = a(8): c(8) = a(8) Else GoTo 80

    For j107 = m1 To m2
    If b(a1(j107)) = 0 Then b(a1(j107)) = a1(j107): c(107) = a1(j107) Else GoTo 1070
    a(107) = a1(j107)

    a(15) = p2 - a(107): If b(a(15)) = 0 Then b(a(15)) = a(15): c(15) = a(15) Else GoTo 150

    a(103) = s1 - a(4) - a(15) - a(26) - a(37) - a(48) - a(59) - a(70) - a(81) - a(92) - a(114)
    If a(103) < a1(m1) Or a(103) > a1(m2) Then GoTo 1030:
    If b1(a(103)) = 0 Then GoTo 1030
    If b(a(103)) = 0 Then b(a(103)) = a(103): c(103) = a(103) Else GoTo 1030
   
    a(19) = p2 - a(103): If b(a(19)) = 0 Then b(a(19)) = a(19): c(19) = a(19) Else GoTo 190

    For j110 = m1 To m2
    If b(a1(j110)) = 0 Then b(a1(j110)) = a1(j110): c(110) = a1(j110) Else GoTo 1100
    a(110) = a1(j110)
    
    a(12) = p2 - a(110): If b(a(12)) = 0 Then b(a(12)) = a(12): c(12) = a(12) Else GoTo 120

    For j99 = m1 To m2
    If b(a1(j99)) = 0 Then b(a1(j99)) = a1(j99): c(99) = a1(j99) Else GoTo 990
    a(99) = a1(j99)
    
    a(23) = p2 - a(99): If b(a(23)) = 0 Then b(a(23)) = a(23): c(23) = a(23) Else GoTo 230

    a(88) = s4 - a(99) - a(110) - a(121)
    If a(88) < a1(m1) Or a(88) > a1(m2) Then GoTo 880:
    If b1(a(88)) = 0 Then GoTo 880
    If b(a(88)) = 0 Then b(a(88)) = a(88): c(88) = a(88) Else GoTo 880
    
    a(34) = p2 - a(88): If b(a(34)) = 0 Then b(a(34)) = a(34): c(34) = a(34) Else GoTo 340

    For j44 = m1 To m2
    If b(a1(j44)) = 0 Then b(a1(j44)) = a1(j44): c(44) = a1(j44) Else GoTo 440
    a(44) = a1(j44)
    
    a(78) = p2 - a(44): If b(a(78)) = 0 Then b(a(78)) = a(78): c(78) = a(78) Else GoTo 780

    For j43 = m1 To m2
    If b(a1(j43)) = 0 Then b(a1(j43)) = a1(j43): c(43) = a1(j43) Else GoTo 430
    a(43) = a1(j43)

    a(79) = p2 - a(43): If b(a(79)) = 0 Then b(a(79)) = a(79): c(79) = a(79) Else GoTo 790

    a(87) = s1 - a(78) - a(79) - a(80) - a(81) - a(82) - a(83) - a(84) - a(85) - a(86) - a(88)
    If a(87) < a1(m1) Or a(87) > a1(m2) Then GoTo 870:
    If b1(a(87)) = 0 Then GoTo 870
    If b(a(87)) = 0 Then b(a(87)) = a(87): c(87) = a(87) Else GoTo 870
   
    a(35) = p2 - a(87): If b(a(35)) = 0 Then b(a(35)) = a(35): c(35) = a(35) Else GoTo 350

t12 = Timer: t13 = t12 - t11                                  'Time Out
If t13 > 60 Then Erase b, c: GoTo 1500                        'Time Out, Try Next

    For j111 = m1 To m2
    If b(a1(j111)) = 0 Then b(a1(j111)) = a1(j111): c(111) = a1(j111) Else GoTo 1110
    a(111) = a1(j111)
    
    a(11) = p2 - a(111): If b(a(11)) = 0 Then b(a(11)) = a(11): c(11) = a(11) Else GoTo 110
    
    For j112 = m1 To m2
    If b(a1(j112)) = 0 Then b(a1(j112)) = a1(j112): c(112) = a1(j112) Else GoTo 1120
    a(112) = a1(j112)
    
    a(10) = p2 - a(112): If b(a(10)) = 0 Then b(a(10)) = a(10): c(10) = a(10) Else GoTo 100
    
    a(113) = s1 - a(111) - a(112) - a(114) - a(115) - a(116) - a(117) - a(118) - a(119) - a(120) - a(121)
    If a(113) < a1(m1) Or a(113) > a1(m2) Then GoTo 1130:
    If b1(a(113)) = 0 Then GoTo 1130
    If b(a(113)) = 0 Then b(a(113)) = a(113): c(113) = a(113) Else GoTo 1130
   
    a(9) = p2 - a(113): If b(a(9)) = 0 Then b(a(9)) = a(9): c(9) = a(9) Else GoTo 90
     
    For j100 = m1 To m2
    If b(a1(j100)) = 0 Then b(a1(j100)) = a1(j100): c(100) = a1(j100) Else GoTo 1000
    a(100) = a1(j100)
    
    a(22) = p2 - a(100): If b(a(22)) = 0 Then b(a(22)) = a(22): c(22) = a(22) Else GoTo 220

    a(89) = s1 - a(1) - a(12) - a(23) - a(34) - a(45) - a(56) - a(67) - a(78) - a(100) - a(111)
    If a(89) < a1(m1) Or a(89) > a1(m2) Then GoTo 890:
    If b1(a(89)) = 0 Then GoTo 890
    If b(a(89)) = 0 Then b(a(89)) = a(89): c(89) = a(89) Else GoTo 890
   
    a(33) = p2 - a(89): If b(a(33)) = 0 Then b(a(33)) = a(33): c(33) = a(33) Else GoTo 330

    For j109 = m1 To m2
    If b(a1(j109)) = 0 Then b(a1(j109)) = a1(j109): c(109) = a1(j109) Else GoTo 1090
    a(109) = a1(j109)
    
    a(13) = p2 - a(109): If b(a(13)) = 0 Then b(a(13)) = a(13): c(13) = a(13) Else GoTo 130
    
    For j108 = m1 To m2
    If b(a1(j108)) = 0 Then b(a1(j108)) = a1(j108): c(108) = a1(j108) Else GoTo 1080
    a(108) = a1(j108)
    
    a(14) = p2 - a(108): If b(a(14)) = 0 Then b(a(14)) = a(14): c(14) = a(14) Else GoTo 140
    
    For j102 = m1 To m2
    If b(a1(j102)) = 0 Then b(a1(j102)) = a1(j102): c(102) = a1(j102) Else GoTo 1020
    a(102) = a1(j102)
    
    a(20) = p2 - a(102): If b(a(20)) = 0 Then b(a(20)) = a(20): c(20) = a(20) Else GoTo 200
    
    a(101) = s1 - a(100) - a(102) - a(103) - a(104) - a(105) - a(106) - a(107) - a(108) - a(109) - a(110)
    If a(101) < a1(m1) Or a(101) > a1(m2) Then GoTo 1010:
    If b1(a(101)) = 0 Then GoTo 1010
    If b(a(101)) = 0 Then b(a(101)) = a(101): c(101) = a(101) Else GoTo 1010
    
    a(21) = p2 - a(101): If b(a(21)) = 0 Then b(a(21)) = a(21): c(21) = a(21) Else GoTo 210

    For j98 = m1 To m2
    If b(a1(j98)) = 0 Then b(a1(j98)) = a1(j98): c(98) = a1(j98) Else GoTo 980
    a(98) = a1(j98)

    a(24) = p2 - a(98): If b(a(24)) = 0 Then b(a(24)) = a(24): c(24) = a(24) Else GoTo 240

    a(90) = s1 - a(2) - a(13) - a(24) - a(35) - a(46) - a(57) - a(68) - a(79) - a(101) - a(112)
    If a(90) < a1(m1) Or a(90) > a1(m2) Then GoTo 900:
    If b1(a(90)) = 0 Then GoTo 900
    If b(a(90)) = 0 Then b(a(90)) = a(90): c(90) = a(90) Else GoTo 900
   
    a(32) = p2 - a(90): If b(a(32)) = 0 Then b(a(32)) = a(32): c(32) = a(32) Else GoTo 320

    a(97) = (2 * s1 / 11 - a(9) - a(20) + a(23) + a(24) + a(26) + a(27) + a(28) + a(29) + a(30) + a(32) + 
                                               + a(33) - a(42) - a(53) - a(64) - a(75) - a(86) - a(108) - a(119)) / 2

    If a(97) < a1(m1) Or a(97) > a1(m2) Or CInt(a(97)) <> a(97) Then GoTo 970:
    If b1(a(97)) = 0 Then GoTo 970
    If b(a(97)) = 0 Then b(a(97)) = a(97): c(97) = a(97) Else GoTo 970
   
    a(25) = p2 - a(97): If b(a(25)) = 0 Then b(a(25)) = a(25): c(25) = a(25) Else GoTo 250

    a(91) = s1 - a(97) - a(89) - a(90) - a(92) - a(93) - a(94) - a(95) - a(96) - a(98) - a(99)
    If a(91) < a1(m1) Or a(91) > a1(m2) Then GoTo 910:
    If b1(a(91)) = 0 Then GoTo 910
    If b(a(91)) = 0 Then b(a(91)) = a(91): c(91) = a(91) Else GoTo 910
   
    a(31) = p2 - a(91): If b(a(31)) = 0 Then b(a(31)) = a(31): c(31) = a(31) Else GoTo 310

'                               Exclude solutions with identical numbers

                                GoSub 1800: If fl1 = 0 Then GoTo 5
    
                                n9 = n9 + 1
                                GoSub 2650              'Print results (squares)
 '                              GoSub 2645              'Print results (selected numbers)
                                Erase b, c: GoTo 1500
5

     b(c(31)) = 0: c(31) = 0
310  b(c(91)) = 0: c(91) = 0
910  b(c(25)) = 0: c(25) = 0
250  b(c(97)) = 0: c(97) = 0
970  b(c(32)) = 0: c(32) = 0
320  b(c(90)) = 0: c(90) = 0
900  b(c(24)) = 0: c(24) = 0
240  b(c(98)) = 0: c(98) = 0
980  Next j98

     b(c(21)) = 0: c(21) = 0
210  b(c(101)) = 0: c(101) = 0
1010 b(c(20)) = 0: c(20) = 0
200  b(c(102)) = 0: c(102) = 0
1020 Next j102

     b(c(14)) = 0: c(14) = 0
140  b(c(108)) = 0: c(108) = 0
1080 Next j108
     
     b(c(13)) = 0: c(13) = 0
130  b(c(109)) = 0: c(109) = 0
1090 Next j109

     b(c(33)) = 0: c(33) = 0
330  b(c(89)) = 0: c(89) = 0
890  b(c(22)) = 0: c(22) = 0
220  b(c(100)) = 0: c(100) = 0
1000 Next j100

     b(c(9)) = 0: c(9) = 0
90   b(c(113)) = 0: c(113) = 0
1130 b(c(10)) = 0: c(10) = 0
100  b(c(112)) = 0: c(112) = 0
1120 Next j112
     
     b(c(11)) = 0: c(11) = 0
110  b(c(111)) = 0: c(111) = 0
1110 Next j111

     b(c(35)) = 0: c(35) = 0
350  b(c(87)) = 0: c(87) = 0
870  b(c(79)) = 0: c(79) = 0
790  b(c(43)) = 0: c(43) = 0
430  Next j43

     b(c(78)) = 0: c(78) = 0
780  b(c(44)) = 0: c(44) = 0
440  Next j44

     b(c(34)) = 0: c(34) = 0
340  b(c(88)) = 0: c(88) = 0
880  b(c(23)) = 0: c(23) = 0
230  b(c(99)) = 0: c(99) = 0
990  Next j99

     b(c(12)) = 0: c(12) = 0
120  b(c(110)) = 0: c(110) = 0
1100 Next j110

     b(c(19)) = 0: c(19) = 0
190  b(c(103)) = 0: c(103) = 0
1030 b(c(15)) = 0: c(15) = 0
150  b(c(107)) = 0: c(107) = 0
1070 Next j107

     b(c(8)) = 0: c(8) = 0
80   b(c(114)) = 0: c(114) = 0
1140 Next j114

     b(c(4)) = 0: c(4) = 0
40   b(c(118)) = 0: c(118) = 0
1180 b(c(3)) = 0: c(3) = 0
30   b(c(119)) = 0: c(119) = 0
1190 Next j119

     b(c(2)) = 0: c(2) = 0
20   b(c(120)) = 0: c(120) = 0
1200 Next j120
     
     b(c(1)) = 0: c(1) = 0
10   b(c(121)) = 0: c(121) = 0
1210 Next j121

     b(c(67)) = 0: c(67) = 0
670  b(c(55)) = 0: c(55) = 0
550  b(c(45)) = 0: c(45) = 0
450  b(c(77)) = 0: c(77) = 0
770  Next j77
     
     b(c(7)) = 0: c(7) = 0
70   b(c(115)) = 0: c(115) = 0
1150 b(c(5)) = 0: c(5) = 0
50   b(c(117)) = 0: c(117) = 0
1170 Next j117

1500 Next j150

    t2 = Timer
    
    t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions"
    y = MsgBox(t10, 0, "Routine AssBrdr11")

End

'    Double Check Identical Numbers a()

1800 fl1 = 1
     For i1 = 1 To 121
        a20 = a(i1): If a20 = 0 Then GoTo 1810
        For i2 = (1 + i1) To 121
            If a20 = a(i2) Then fl1 = 0: Return
        Next i2
1810 Next i1
     Return

'   Print results (selected numbers)

2645 For i1 = 1 To 121
         Cells(n9, i1).Value = a(i1)
     Next i1
     Cells(n9, 122).Value = n9
     Return

'    Print results (squares)

2650 n2 = n2 + 1
     If n2 = 4 Then
         n2 = 1: k1 = k1 + 12: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 12
     End If

     Cells(2, 1).Value = n9
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = n9
     Cells(k1, k2 + 2).Value = j150
   
     Sheets("DiaLns56").Cells(j150, 123).Value = "ok"
   
     i3 = 0
     For i1 = 1 To 11
         For i2 = 1 To 11
         i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1

     Return

End Sub

Vorige Pagina About the Author