Skip to content

Instantly share code, notes, and snippets.

@Sneezry Sneezry/Sudoku.BAS
Created Feb 3, 2017

Embed
What would you like to do?
10 GRAPH
20 LOCATE 2,5:PRINT "Sudoku Group","Copy by SNAIL (2006)"
21 LOCATE 4,16:PRINT "[3.0]"
30 LOCATE 5,10:PRINT "SNAIL Soft";
40 W$=INKEY$
41 CLS:PRINT "1.Easy","2.Middle","3.Hard","4.From Files"
42 LOCATE 5,10:PRINT "SNAIL Soft";
43 W$=INKEY$
44 IF ASC(W$)=98 THEN L=10:DJ$="EASY":50
45 IF ASC(W$)=110 THEN L=9:DJ$="MIDDLE":50
46 IF ASC(W$)=109 THEN L=8:DJ$="HARD":50
47 IF ASC(W$)=103 THEN DJ$="File":1450
48 BEEP:GOTO 43
50 CLS:PRINT "Working Out..."
60 FOR Y=1 TO 9
61 FOR X=1 TO 9
69 IF RND(1)*40<L THEN 71
70 A(X,Y)=0:GOTO 190
71 T=PEEK(1015)*3600+PEEK(1016)*60+PEEK(1017)/2
72 IF PEEK(1015)*3600+PEEK(1016)*60+PEEK(1017)/2-T>5 THEN 50
73 A(X,Y)=INT(RND(1)*10)
74 IF A(X,Y)>9 THEN 72
75 IF X=1 THEN 83
80 FOR A=1 TO X-1
81 IF A(X,Y)=A(A,Y)THEN 72
82 NEXT A
83 IF Y=1 THEN 90
84 FOR B=1 TO Y-1
85 IF A(X,Y)=A(X,B)THEN 72
86 NEXT B
90 IF(X-1)/3=INT((X-1)/3)THEN IF(Y-1)/3=INT((Y-1)/3)THEN 92
91 GOTO 100
92 IF A(X,Y)=A(X+1,Y)OR A(X,Y)=A(X+2,Y)OR A(X,Y)=A(X+1,Y+1)THEN 72
93 IF A(X,Y)=A(X+2,Y+1)OR A(X,Y)=A(X+1,Y+2)OR A(X,Y)=A(X+2,Y+2)THEN 72
100 IF(X-2)/3=INT((X-2)/3)AND(Y-1)/3=INT((Y-1)/3)THEN 102
101 GOTO 110
102 IF A(X,Y)=A(X-1,Y)OR A(X,Y)=A(X+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y)=A(X+2,Y-1)OR A(X,Y)=A(X+1,Y)OR A(X,Y)=A(X+2,Y)THEN 72
160 IF(X-2)/3=INT((X-2)/3)THEN IF Y/3=INT(Y/3)THEN 162
161 GOTO 170
162 IF A(X,Y)=A(X+1,Y-2)OR A(X,Y)=A(X-1,Y-2)OR A(X,Y)=A(X+1,Y-1)THEN 72
163 IF A(X,Y)=A(X-1,Y-1)OR A(X,Y)=A(X+1,Y)OR A(X,Y)=A(X-1,Y)THEN 72
170 IF X/3=INT(X/3)THEN IF Y/3=INT(Y/3)THEN 172
171 GOTO 180
172 IF A(X,Y)=A(X-2,Y-2)OR A(X,Y)=A(X-1,Y-2)OR A(X,Y)=A(X-2,Y-1)THEN 72
173 IF A(X,Y)=A(X-1,Y-1)OR A(X,Y)=A(X-2,Y)OR A(X,Y)=A(X-1,Y)THEN 72
180 LOCATE 2,1:PRINT X;",";Y
190 NEXT X
200 NEXT Y
210 CLS:PRINT "Marking Numbers..."
220 FOR Y=1 TO 9
230 FOR X=1 TO 9
240 IF A(X,Y)=0 THEN B(X,Y)=0 ELSE B(X,Y)=1
250 LOCATE 2,1:PRINT X;",";Y
260 NEXT X
270 NEXT Y
280 CLS:LOCATE 1,14:PRINT DJ$
290 BOX 4,4,76,76
300 FOR A=4 TO 76 STEP 2
301 DRAW A,28
302 NEXT A
310 FOR A=4 TO 76 STEP 2
311 DRAW A,52
312 NEXT A
320 FOR A=4 TO 76 STEP 2
321 DRAW 28,A
322 NEXT A
330 FOR A=4 TO 76 STEP 2
331 DRAW 52,A
332 NEXT A
340 FOR Y=1 TO 9
350 FOR X=1 TO 9
360 IF A(X,Y)=0 THEN 480
370 BOX X*8-3,Y*8-3,X*8+3,Y*8+3,1
380 IF A(X,Y)=1 THEN C(1,1)=1:C(1,2)=1:C(2,1)=1:C(3,1)=1:C(3,2)=1:C(4,1)=1:C(5,1)=1:C(5,2)=1
390 IF A(X,Y)=2 THEN C(2,1)=1:C(4,3)=1
400 IF A(X,Y)=3 THEN C(2,1)=1:C(4,1)=1
410 IF A(X,Y)=4 THEN C(1,2)=1 :C(4,1)=1:C(5,1)=1:C(5,2)=1
420 IF A(X,Y)=5 THEN C(2,3)=1:C(4,1)=1
430 IF A(X,Y)=6 THEN C(2,3)=1
440 IF A(X,Y)=7 THEN C(2,1)=1:C(3,1)=1:C(3,2)=1:C(4,1)=1:C(5,1)=1:C(5,2)=1
450 IF A(X,Y)=9 THEN C(4,1)=1
460 DRAW X*8-1,Y*8-2,C(1,1)
461 DRAW X*8,Y*8-2,C(1,2)
462 DRAW X*8+1,Y*8-2,C(1,3)
463 DRAW X*8-1,Y*8-1,C(2,1)
464 DRAW X*8+1,Y*8-1,C(2,3)
465 DRAW X*8-1,Y*8,C(3,1)
466 DRAW X*8,Y*8,C(3,2)
467 DRAW X*8+1,Y*8,C(3,3)
468 DRAW X*8-1,Y*8+1,C(4,1)
469 DRAW X*8+1,Y*8+1,C(4,3)
470 DRAW X*8-1,Y*8+2,C(5,1)
471 DRAW X*8,Y*8+2,C(5,2)
472 DRAW X*8+1,Y*8+2,C(5,3)
473 C(1,1)=0:C(1,2)=0:C(1,3)=0:C(2,1)=0:C(2,3)=0:C(3,1)=0:C(3,2)=0:C(3,3)=0:C(4,1)=0:C(4,3)=0
474 C(5,1)=0:C(5,2)=0:C(5,3)=0
480 NEXT X
490 NEXT Y
500 X=1:Y=1
510 BOX X*8-3,Y*8-3,X*8+3,Y*8+3,0,2:XA=X:YA=Y
520 W$=INKEY$
521 IF ASC(W$)>19 AND ASC(W$)<24 THEN 530 ELSE 630
530 IF ASC(W$)=20 THEN Y=Y-1
540 IF Y<1 THEN Y=1:BEEP:520
550 IF ASC(W$)=21 THEN Y=Y+1
560 IF Y>9 THEN Y=9:BEEP:520
570 IF ASC(W$)=23 THEN X=X-1
580 IF X<1 THEN X=1:BEEP:520
590 IF ASC(W$)=22 THEN X=X+1
600 IF X>9 THEN X=9:BEEP:520
610 BOX XA*8-3,YA*8-3,XA*8+3,YA*8+3,0,2
620 GOTO 510
630 IF ASC(W$)=13 THEN 1070
640 IF B(X,Y)=1 THEN BEEP:520
650 IF ASC(W$)=98 THEN 670
651 IF ASC(W$)=110 THEN 700
652 IF ASC(W$)=109 THEN 730
653 IF ASC(W$)=103 THEN 760
654 IF ASC(W$)=104 THEN 781
655 IF ASC(W$)=106 THEN 790
656 IF ASC(W$)=116 THEN 820
657 IF ASC(W$)=121 THEN 850
658 IF ASC(W$)=117 THEN 880
660 BEEP:GOTO 520
670 A(X,Y)=1
680 C(1,3)=1:C(2,3)=1:C(3,3)=1:C(4,3)=1:C(5,3)=1
690 GOTO 900
700 A(X,Y)=2
710 C(1,1)=1:C(1,2)=1:C(1,3)=1:C(2,3)=1:C(3,1)=1:C(3,2)=1:C(3,3)=1:C(4,1)=1:C(5,1)=1:C(5,2)=1
711 C(5,3)=1
720 GOTO 900
730 A(X,Y)=3
740 C(1,1)=1:C(1,2)=1:C(1,3)=1:C(2,3)=1:C(3,1)=1:C(3,2)=1:C(3,3)=1:C(4,3)=1:C(5,1)=1:C(5,2)=1
741 C(5,3)=1
750 GOTO 900
760 A(X,Y)=4
770 C(1,1)=1:C(1,3)=1:C(2,1)=1:C(2,3)=1:C(3,1)=1:C(3,2)=1:C(3,3)=1:C(4,3)=1:C(5,3)=1
780 GOTO 900
781 A(X,Y)=5
782 C(1,1)=1:C(1,2)=1:C(1,3)=1:C(2,1)=1:C(3,1)=1:C(3,2)=1:C(3,3)=1:C(4,3)=1:C(5,1)=1:C(5,2)=1
783 C(5,3)=1
784 GOTO 900
790 A(X,Y)=6
800 C(1,1)=1:C(1,2)=1:C(1,3)=1:C(2,1)=1:C(3,1)=1:C(3,2)=1:C(3,3)=1:C(4,1)=1:C(4,3)=1:C(5,1)=1
801 C(5,2)=1:C(5,3)=1
810 GOTO 900
820 A(X,Y)=7
830 C(1,1)=1:C(1,2)=1:C(1,3)=1:C(2,3)=1:C(3,3)=1:C(4,3)=1:C(5,3)=1
840 GOTO 900
850 A(X,Y)=8
860 C(1,1)=1:C(1,2)=1:C(1,3)=1:C(2,1)=1:C(2,3)=1:C(3,1)=1:C(3,2)=1:C(3,3)=1:C(4,1)=1:C(4,3)=1
861 C(5,1)=1:C(5,2)=1:C(5,3)=1
870 GOTO 900
880 A(X,Y)=9
890 C(1,1)=1:C(1,2)=1:C(1,3)=1:C(2,1)=1:C(2,3)=1:C(3,1)=1:C(3,2)=1:C(3,3)=1:C(4,3)=1:C(5,1)=1
891 C(5,2)=1:C(5,3)=1
900 BOX X*8-2,Y*8-2,X*8+2,Y*8+2,1,0
910 DRAW X*8-1,Y*8-2,C(1,1)
920 DRAW X*8,Y*8-2,C(1,2)
930 DRAW X*8+1,Y*8-2,C(1,3)
940 DRAW X*8-1,Y*8-1,C(2,1)
950 DRAW X*8+1,Y*8-1,C(2,3)
960 DRAW X*8-1,Y*8,C(3,1)
970 DRAW X*8,Y*8,C(3,2)
980 DRAW X*8+1,Y*8,C(3,3)
990 DRAW X*8-1,Y*8+1,C(4,1)
1000 DRAW X*8+1,Y*8+1,C(4,3)
1010 DRAW X*8-1,Y*8+2,C(5,1)
1020 DRAW X*8,Y*8+2,C(5,2)
1030 DRAW X*8+1,Y*8+2,C(5,3)
1040 C(1,1)=0:C(1,2)=0:C(1,3)=0:C(2,1)=0:C(2,3)=0:C(3,1)=0:C(3,2)=0:C(3,3)=0:C(4,1)=0:C(4,3)=0
1050 C(5,1)=0:C(5,2)=0:C(5,3)=0
1060 GOTO 520
1070 LOCATE 2,11:PRINT " Checking ":A=0:B=0
1080 FOR Y=1 TO 9
1090 FOR X=1 TO 9
1100 A=A+A(X,Y)
1110 B=B+A(X,Y)^2
1120 NEXT X
1130 IF A=45 THEN 1150
1140 IF B=285 THEN 1150
1141 GOTO 1350
1150 A=0:B=0
1160 NEXT Y
1161 A=0:B=0
1170 FOR X=1 TO 9
1180 FOR Y=1 TO 9
1190 A=A+A(X,Y)
1200 B=B+A(X,Y)^2
1201 NEXT Y
1210 IF A=45 THEN 1230
1220 IF B=285 THEN 1230
1221 GOTO 1350
1230 A=0:B=0
1240 NEXT X
1250 FOR Y=1 TO 7 STEP 3
1260 FOR X=1 TO 7 STEP 3
1270 A=A(X,Y)+A(X+1,Y)+A(X+2,Y)+A(X,Y+1)+A(X+1,Y+1)+A(X+2,Y+1)+A(X,Y+2)+A(X+1,Y+2)+A(X+2,Y+2)
1280 B=A(X,Y)^2+A(X+1,Y)^2+A(X+2,Y)^2+A(X,Y+1)^2+A(X+1,Y+1)^2+A(X+2,Y+1)^2+A(X,Y+2)^2
1290 B=B+A(X+1,Y+2)^2+A(X+2,Y+2)^2
1300 IF A=45 THEN 1320
1310 IF B=285 THEN 1320
1311 GOTO 1350
1320 A=0:B=0
1330 NEXT X
1340 NEXT Y
1341 GOTO 1351
1350 LOCATE 2,11:PRINT "YOU LOST!":GOTO 1360
1351 LOCATE 2,11:PRINT "VERY GOOD!"
1360 LOCATE 3,11:PRINT " Another? "
1370 LOCATE 4,11:PRINT " (Yes/No) "
1380 W$=INKEY$
1390 IF ASC(W$)=121 THEN 41
1400 IF ASC(W$)=110 THEN 1420
1410 BEEP:GOTO 1380
1420 CLS:LOCATE 2,8:PRINT "SUDOKU"," www.SUDOKU.name"
1430 LOCATE 5,10:PRINT "SNAIL Soft";
1440 END
1450 TEXT:CLS:INPUT "File Name:";NA$
1460 GRAPH:CLS:PRINT "Opening File ";NA$;".sud.DAT..."
1461 OPEN NA$+".sud" FOR INPUT AS #1
1470 FOR Y=1 TO 9
1480 FOR X=1 TO 9
1490 INPUT #1,A(X,Y)
1491 IF A(X,Y)=0 THEN B(X,Y)=0 ELSE B(X,Y)=1
1500 LOCATE 3,1:PRINT X;",";Y
1510 NEXT X
1520 NEXT Y
1521 CLOSE #1
1530 GOTO 280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.