10 DIM A(5, 11), B(10), C(10), D(10)
11 OPEN "MK21.txt" FOR OUTPUT AS #1
12 A(4, 1) = 1: A(4, 2) = 2: A(4, 3) = 5: A(4, 4) = 9: A(4, 5) = 6: A(4, 6) = 0: A(4, 7) = 4: A(4, 8) = 3: A(4, 9) = 8: A(4, 10) = 1: A(4, 11) = 7
13 A(3, 1) = 1: A(3, 2) = 1: A(3, 3) = 9: A(3, 4) = 5: A(3, 5) = 8: A(3, 6) = 3
14 A(3, 7) = 2: A(3, 8) = 7: A(3, 9) = 0: A(3, 10) = 6: A(3, 11) = 4
15 A(1, 1) = 9
20 FOR I = 2 TO 11: A(1, I) = 0: NEXT I
22 A(2, 1) = 0: A(2, 2) = 9: A(2, 3) = 0
24 FOR J = 4 TO 11: A(2, J) = A(2, J - 1) + 1: NEXT J
26 FOR I = 0 TO 8
28 FOR J = 0 TO 8
30 IF J = I THEN 545
31 FOR K = 0 TO 8
32 IF K <> I THEN IF K <> J THEN 36
34 GOTO 540
36 FOR L = 0 TO 8
38 IF L <> J THEN IF L <> K THEN 42
40 GOTO 535
42 FOR M = 0 TO 9
44 IF M <> J THEN IF M <> K THEN IF M <> L THEN 48
46 GOTO 530
48 FOR N = 0 TO 9
50 IF N <> J THEN IF N <> K THEN IF N <> L THEN IF N <> M THEN 54
52 GOTO 525
54 FOR P = 0 TO 9
56 IF P <> J THEN IF P <> K THEN IF P <> L THEN IF P <> M THEN IF P <> N THEN 60
58 GOTO 520
60 FOR Q = 0 TO 9
62 IF Q <> J THEN IF Q <> K THEN IF Q <> L THEN IF Q <> M THEN IF Q <> N THEN IF Q <> P THEN 66
64 GOTO 515
66 FOR R = 0 TO 9
68 IF R <> J THEN IF R <> K THEN IF R <> L THEN IF R <> M THEN IF R <> N THEN IF R <> P THEN IF R <> Q THEN 72
70 GOTO 510
72 FOR S = 0 TO 9
74 IF S <> J THEN IF S <> K THEN IF S <> L THEN IF S <> M THEN IF S <> N THEN IF S <> P THEN IF S <> Q THEN IF S <> R THEN 78
76 GOTO 505
78 FOR T = 0 TO 9
80 IF T <> J THEN IF T <> K THEN IF T <> L THEN IF T <> M THEN IF T <> N THEN IF T <> P THEN IF T <> Q THEN IF T <> R THEN IF T <> S THEN 90
82 GOTO 500
90 A(5, 1) = I: A(5, 2) = J: A(5, 3) = K: A(5, 4) = L: A(5, 5) = M
92 A(5, 6) = N: A(5, 7) = P: A(5, 8) = Q: A(5, 9) = R: A(5, 10) = S: A(5, 11) = T
94 B(1) = I: B(2) = K: B(3) = L - 1
96 IF M = 9 THEN B(4) = 9: GOTO 100
98 B(4) = M - 2
100 IF N = 9 THEN B(5) = 9: GOTO 104
102 B(5) = N - 3
104 IF P = 9 THEN B(6) = 9: GOTO 108
106 B(6) = P - 4
108 IF Q = 9 THEN B(7) = 9: GOTO 112
110 B(7) = Q - 5
112 IF R = 9 THEN B(8) = 9: GOTO 116
114 B(8) = R - 6
116 IF S = 9 THEN B(9) = 9: GOTO 120
118 B(9) = S - 7
120 IF T = 9 THEN B(10) = 9: GOTO 132
122 B(10) = T - 8
132 FOR W = 1 TO 10
134 IF B(W) < 0 THEN B(W) = B(W) + 9
136 NEXT W
138 FOR X = 1 TO 9
140 FOR Y = 1 TO 9
142 IF X = Y THEN 150
144 IF B(X) = B(Y) THEN 500
150 NEXT Y
152 NEXT X
154 C(1) = I - 1: C(2) = J - 1: C(3) = L - 5
156 IF M = 9 THEN C(4) = 9: GOTO 160
158 C(4) = M - 8
160 IF N = 9 THEN C(5) = 9: GOTO 164
162 C(5) = N - 3
164 IF P = 9 THEN C(6) = 9: GOTO 168
166 C(6) = P - 2
168 IF Q = 9 THEN C(7) = 9: GOTO 172
170 C(7) = Q - 7
172 IF R = 9 THEN C(8) = 9: GOTO 176
174 C(8) = R
176 IF S = 9 THEN C(9) = 9: GOTO 180
178 C(9) = S - 6
180 IF T = 9 THEN C(10) = 9: GOTO 184
182 C(10) = T - 4
184 FOR W = 1 TO 10
186 IF C(W) < 0 THEN C(W) = C(W) + 9
188 NEXT W
190 FOR X = 1 TO 10
192 FOR Y = 1 TO 10
194 IF Y = X THEN 198
196 IF C(X) = C(Y) THEN 500
198 NEXT Y
200 NEXT X
201 D(1) = I - 1: D(2) = J - 2: D(3) = K - 5
202 IF M = 9 THEN D(4) = 9: GOTO 206
204 D(4) = M - 6
206 IF N = 9 THEN D(5) = 9: GOTO 210
208 D(5) = N
210 IF P = 9 THEN D(6) = 9: GOTO 214
212 D(6) = P - 4
214 IF Q = 9 THEN D(7) = 9: GOTO 218
216 D(7) = Q - 3
218 IF R = 9 THEN D(8) = 9: GOTO 222
220 D(8) = R - 8
222 IF S = 9 THEN D(9) = 9: GOTO 226
224 D(9) = S - 1
226 IF T = 9 THEN D(10) = 9: GOTO 230
228 D(10) = T - 7
230 FOR W = 1 TO 10
232 IF D(W) < 0 THEN D(W) = D(W) + 9
234 NEXT W
236 FOR X = 1 TO 10
238 FOR Y = 1 TO 10
240 IF Y = X THEN 244
242 IF D(X) = D(Y) THEN 500
244 NEXT Y
246 NEXT X
370 FOR X = 1 TO 5
372 FOR Y = 1 TO 11
374 PRINT A(X, Y);
375 PRINT #1, A(X, Y);
376 NEXT Y
378 PRINT : PRINT #1,
380 NEXT X
382 PRINT : PRINT #1,
500 NEXT T
505 NEXT S
510 NEXT R
515 NEXT Q
520 NEXT P
525 NEXT N
530 NEXT M
535 NEXT L
540 NEXT K
545 NEXT J
550 NEXT I
600 END