Skip to content

Instantly share code, notes, and snippets.

@Sneezry
Created May 10, 2021 19:37
Show Gist options
  • Save Sneezry/15e06b936bcd2dc05eb850408bc54da8 to your computer and use it in GitHub Desktop.
Save Sneezry/15e06b936bcd2dc05eb850408bc54da8 to your computer and use it in GitHub Desktop.
10 GRAPH:GOTO 1541
20 CLS:LOCATE 2,4:PRINT "SUDOKU":LOCATE 2,13:PRINT "Solver"
30 LOCATE 3,1:PRINT "Copy":LOCATE 3,6:PRINT "by":LOCATE 3,9:PRINT "SNAIL"
40 LOCATE 3,15:PRINT "(2007)":LOCATE 5,10:PRINT "SNAIL";:LOCATE 5,16:PRINT "Soft";
41 LOCATE 4,1:PRINT "[English]"
50 BOX 1,1,53,26,1,2
60 BOX 107,1,159,26,1,2
70 BOX 54,27,106,52,1,2
80 BOX 1,53,53,78,1,2
90 BOX 107,53,159,78,1,2
91 OPEN "SUDAT"FOR RANDOM AS#1
92 IF LOF (1)>0 THEN SW=1
93 CLOSE #1
100 W$= INKEY$
110 GOTO 1200
140 BOX 1,1,73,73
141 FOR S=1 TO 73 STEP 2
142 DRAW 25,S:DRAW 49,S:DRAW S,25:DRAW S,49
143 NEXT S
144 IF FL=1 THEN 196
150 X=1:Y=1:BOX 2+(X-1)*8,2+(Y-1)*8,8+(X-1)*8,8+(Y-1)*8,0,2
151 XA=X:YA=Y:K$= INKEY$:R=ASC(K$)
152 IF R=20 THEN Y=Y-1:165
153 IF R=21 THEN Y=Y+1:166
154 IF R=23 THEN X=X-1:167
155 IF R=22 THEN X=X+1:168
156 GOTO 170
165 IF Y<1 THEN Y=9
166 IF Y>9 THEN Y=1
167 IF X<1 THEN X=9
168 IF X>9 THEN X=1
169 GOTO 187
170 IF R=98 AND D(X,Y)=0 THEN D=1:190
171 IF R=110 AND D(X,Y)=0 THEN D=2:190
172 IF R=109 AND D(X,Y)=0 THEN D=3:190
173 IF R=103 AND D(X,Y)=0 THEN D=4:190
174 IF R=104 AND D(X,Y)=0 THEN D=5:190
175 IF R=106 AND D(X,Y)=0 THEN D=6:190
176 IF R=116 AND D(X,Y)=0 THEN D=7:190
177 IF R=121 AND D(X,Y)=0 THEN D=8:190
178 IF R=117 AND D(X,Y)=0 THEN D=9:190
179 IF R=13 THEN 292
180 GOTO 151
187 BOX 2+(XA-1)*8,2+(YA-1)*8,8+(XA-1)*8,8+(YA-1)*8,0,2
188 BOX 2+(X-1)*8,2+(Y-1)*8,8+(X-1)*8,8+(Y-1)*8,0,2
189 GOTO 151
190 IF D(X,Y)>0 THEN BEEP:151
191 IF X(X,D)=1 THEN BEEP:151
192 IF Y(Y,D)=1 THEN BEEP:151
193 GX=INT((X-1)/3)+1:GY=INT((Y-1)/3)+1:G=GX+(GY-1)*3
194 IF G(G,D)=1 THEN BEEP:151
195 GOTO 200
196 FOR Y=1 TO 9
197 FOR X=1 TO 9
198 INPUT #1,D:IF D=0 THEN 1180
199 GX=INT((X-1)/3)+1:GY=INT((Y-1)/3)+1:G=GX+(GY-1)*3
200 Z=Z+1:D(X,Y)=D
210 X(X,D)=1
240 Y(Y,D)=1
270 G(G,D)=1
291 GOTO 800
292 LOCATE 1,11:PRINT "S ";PEEK(1015);":";PEEK(1016);":";PEEK(1017)/2
293 IF FL=0 THEN BOX 2+(X-1)*8,2+(Y-1)*8,8+(X-1)*8,8+(Y-1)*8,0,2
294 BOX 78,20,152,29
295 Z=81-Z
296 LOCATE 3,11:PRINT "Solving"
297 LOCATE 4,11:PRINT "SNAIL":LOCATE 5,16:PRINT "Soft";
300 C=0
310 FOR Y=1 TO 9
320 FOR X=1 TO 9
330 IF D(X,Y)=0 THEN 370
340 NEXT X
350 NEXT Y
351 IF C=1 THEN 300
352 FOR Y=1 TO 9
353 FOR X=1 TO 9
354 IF D(X,Y)=0 THEN 750
355 NEXT X:NEXT Y
360 LOCATE 3,11:PRINT "E ";PEEK(1015);":";PEEK(1016);":";PEEK(1017)/2
361 LOCATE 4,11:PRINT "SNAIL":LOCATE 5,16:PRINT "Soft";
362 W$= INKEY$
363 CLS:LOCATE 3,2:PRINT "??"
370 GX=INT((X-1)/3)+1:GY=INT((Y-1)/3)+1:G=GX+(GY-1)*3
380 FOR D=1 TO 9
390 IF X(X,D)=1 THEN N(D)=1
400 IF Y(Y,D)=1 THEN N(D)=1
410 IF G(G,D)=1 THEN N(D)=1
420 NEXT D
421 T=0
430 FOR D=1 TO 9
440 IF N(D)=1 THEN T=T+2^(D-1)
450 NEXT D
640 IF T=255 THEN D(X,Y)=9:C=1:P=P+1:800
650 IF T=383 THEN D(X,Y)=8:C=1:P=P+1:800
660 IF T=447 THEN D(X,Y)=7:C=1:P=P+1:800
670 IF T=479 THEN D(X,Y)=6:C=1:P=P+1:800
680 IF T=495 THEN D(X,Y)=5:C=1:P=P+1:800
690 IF T=503 THEN D(X,Y)=4:C=1:P=P+1:800
700 IF T=507 THEN D(X,Y)=3:C=1:P=P+1:800
710 IF T=509 THEN D(X,Y)=2:C=1:P=P+1:800
715 IF T=510 THEN D(X,Y)=1:C=1:P=P+1:800
717 FOR D=1 TO 9
718 N(D)=0
719 NEXT D
720 GOTO 740
721 D=D(X,Y):GX=INT((X-1)/3)+1:GY=INT((Y-1)/3)+1:G=GX+(GY-1)*3
722 X(X,D)=1
724 Y(Y,D)=1
726 G(G,D)=1
728 FOR D=1 TO 9
729 N(D)=0:NEXT D
730 BOX 80,22,80+P/Z*70,27,1
731 IF W=1 THEN W=0:300
740 NEXT X:NEXT Y
750 IF C=0 THEN 985 ELSE 760
751 LOCATE 3,11:PRINT "No Key!"
752 LOCATE 4,11:PRINT "SNAIL":LOCATE 5,16:PRINT "Soft";:END
760 GOTO 300
790 IF D(X,Y)=0 THEN 980
800 IF D(X,Y)=1 THEN H(3)=1:I(2)=1:J(3)=1:K(2)=1:L(3)=1
810 IF D(X,Y)=2 THEN H(1)=1:H(2)=1:H(3)=1:I(2)=1:J(1)=1:J(2)=1:J(3)=1:K(1)=1:L(1)=1:L(2)=1
820 IF D(X,Y)=2 THEN L(3)=1
830 IF D(X,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 THEN GC=GC+1
1070 IF D(X,Y+YC)>0 OR Y(Y+YC,D)=1 THEN GC=GC+1
1080 IF D(X+XC,Y+YC)>0 OR X(X+XC,D)=1 OR Y(Y+YC,D)=1 THEN GC=GC+1
1090 IF GC=8 THEN D(X,Y)=D:C=1:P=P+1:W=1:800
1100 GC=0:NEXT D
1110 NEXT X
1120 NEXT Y
1130 GOTO 751
1140 TEXT:CLS
1150 INPUT "File Name:";FN$
1160 OPEN FN$+".sud"FOR INPUT AS#1
1170 GRAPH:CLS:GOTO 140
1180 NEXT X:NEXT Y
1190 GOTO 292
1200 CLS
1210 BOX 13,13,149,69,1
1220 BOX 11,11,147,67,1,0
1230 BOX 11,11,147,67
1240 IF CH=0 THEN CA$=" by ":CB$="keyboard"ELSE IF CH=1 THEN CA$="from":CB$=" file "
1241 IF CH=2 THEN CA$="from":CB$="software"
1250 LOCATE 3,3:PRINT CHR$(17)
1260 LOCATE 3,18:PRINT CHR$(16)
1270 LOCATE 2,8:PRINT "Input:"
1280 LOCATE 3,9:PRINT CA$
1290 LOCATE 4,7:PRINT CB$
1300 W$= INKEY$
1310 W=ASC(W$)
1320 IF W=21 OR W=22 THEN CH=CH+1:1350
1321 IF W=20 OR W=23 THEN CH=CH-1:1350
1330 IF W=13 THEN 1370
1340 BEEP:GOTO 1300
1350 IF SW=1 AND CH>2 THEN CH=0 ELSE IF SW=1 AND CH<0 THEN CH=2
1351 IF SW=0 AND CH>1 THEN CH=0 ELSE IF SW=0 AND CH<0 THEN CH=1
1360 GOTO 1240
1370 IF CH=0 THEN CLS:140 ELSE IF CH=1 THEN CLS:FL=1:1140
1380 CLS:PRINT "Unpacking Now..."
1390 OPEN "SUDAT" FOR INPUT AS#1
1400 INPUT #1,A$,B$,A,B,C
1410 CLS:PRINT A$,B$
1411 LOCATE 5,10:PRINT "SNAIL Soft";
1420 LOCATE 3,1:PRINT "No. ";NO+1;" "
1430 W$= INKEY$
1440 IF ASC(W$)=20 OR ASC(W$)=23 THEN NO=NO-1:1460
1450 IF ASC(W$)=21 OR ASC(W$)=22 THEN NO=NO+1:1470
1451 IF ASC(W$)=13 THEN 1480
1452 BEEP:GOTO 1430
1460 IF NO<0 THEN NO=C-1
1470 IF NO+1>C THEN NO=0
1471 GOTO 1420
1480 CLS:PRINT "Unpacking Now..."
1481 IF NO=0 THEN 1530
1490 FOR A=1 TO NO
1500 FOR B=1 TO 81
1510 INPUT #1,C
1520 NEXT B:NEXT A
1530 CLS:FL=1:GOTO 140
1541 LINE 50,21,54,21
1542 LINE 49,22,55,22:LINE 66,22,94,22
1543 LINE 48,23,56,23:LINE 66,23,95,23
1544 LINE 48,24,56,24:LINE 66,24,95,24
1545 LINE 48,25,56,25:LINE 65,25,95,25
1546 LINE 48,26,56,26:LINE 65,26,95,26
1547 LINE 48,27,56,27:LINE 65,27,95,27
1548 LINE 49,28,55,28:LINE 64,28,95,28
1549 LINE 50,29,54,29:LINE 64,29,96,29
1550 LINE 63,30,96,30
1551 LINE 63,31,69,31:LINE 90,31,96,31
1552 LINE 63,32,69,32:LINE 90,32,96,32
1553 LINE 63,33,69,33:LINE 90,33,97,33
1554 DRAW 53,34:LINE 62,34,68,34:DRAW 80,34:LINE 90,34,97,34
1555 DRAW 53,35:LINE 62,35,68,35:LINE 79,35,80,35:LINE 90,35,97,35
1556 LINE 34,36,38,36:DRAW 53,36:LINE 61,36,68,36:LINE 78,36,79,36:LINE 90,36,97,36
1557 LINE 33,37,39,37:LINE 53,37,54,37:LINE 61,37,68,37:LINE 77,37,79,37:LINE 90,37,97,37
1558 LINE 32,38,40,38:LINE 53,38,54,38:LINE 61,38,67,38:LINE 76,38,79,38:LINE 90,38,97,38
1559 LINE 32,39,40,39:LINE 53,39,54,39:LINE 60,39,67,39:LINE 75,39,78,39:LINE 91,39,98,39
1560 LINE 32,40,40,40:LINE 53,40,55,40:LINE 60,40,67,40:LINE 74,40,77,40:LINE 91,40,98,40
1561 LINE 32,41,40,41:LINE 53,41,55,41:LINE 59,41,66,41:LINE 73,41,77,41:LINE 91,41,98,41
1562 LINE 32,42,40,42:LINE 53,42,56,42:LINE 59,42,66,42:LINE 72,42,76,42:LINE 91,42,98,42
1563 LINE 33,43,39,43:LINE 53,43,56,43:LINE 59,43,66,43:LINE 71,43,76,43:LINE 91,43,99,43
1564 LINE 34,44,38,44:LINE 53,44,56,44:LINE 58,44,65,44:LINE 70,44,75,44:LINE 91,44,99,44
1565 LINE 53,45,65,45:LINE 69,45,75,45:LINE 92,45,99,45
1566 DRAW 42,46:LINE 53,46,65,46:LINE 68,46,74,46:LINE 92,46,99,46:LINE 116,46,117,46
1567 LINE 42,47,45,47:LINE 53,47,65,47:LINE 67,47,74,47:LINE 92,47,99,47:LINE 113,47,116,47
1568 LINE 43,48,47,48:LINE 53,48,74,48:LINE 92,48,99,48:LINE 110,48,114,48:LINE 44,49,48,49
1569 LINE 53,49,74,49:LINE 78,49,81,49:LINE 92,49,100,49:LINE 107,49,113,49
1570 LINE 46,50,73,50:LINE 81,50,90,50:LINE 92,50,100,50:LINE 102,50,112,50
1571 LINE 46,51,73,51:LINE 83,51,110,51
1572 LINE 47,52,72,52:LINE 84,52,109,52
1573 LINE 48,53,72,53:LINE 85,53,108,53
1574 LINE 48,54,71,54:LINE 87,54,107,54
1575 LINE 49,55,71,55:LINE 88,55,105,55
1576 LINE 49,56,70,56:LINE 90,56,104,56
1577 LINE 50,57,70,57:LINE 92,57,103,57
1578 LINE 51,58,70,58:LINE 93,58,102,58
1579 LINE 53,59,69,59:LINE 95,59,100,59
1580 LINE 53,60,68,60:LINE 97,60,99,60
1590 LOCATE 5,10:PRINT "SNAIL Soft";
1600 W$= INKEY$
1610 GOTO 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment