I never made a sudoku

I did code some C# sources that solve it

I made sudoku's by hand, ah its okay

I was bored, so went to MeitsNeardark's place

I don't have a running MSX, only openMSX.. Jelle has one

I coded a lame BASIC program that solves it, thnx Jelle

FYI: It uses backtracking, not recursive.. how would i ever recurse in basic without using assembly? and btw: recursion sucks in this case, iterations are faster because we don't call the method/function all the time.. it also prevents a segfault or stackoverflowexeption.. at least mono does segfault... bla bla bla

10 DATA 0,2,0,0,0,0,0,8,0 20 DATA 0,0,8,0,9,0,0,0,7 30 DATA 3,0,0,0,0,1,0,2,0 40 DATA 2,0,5,1,7,0,0,0,4 50 DATA 0,0,0,8,0,2,0,0,0 60 DATA 9,0,0,0,5,6,1,0,2 70 DATA 0,9,0,7,0,0,0,0,5 80 DATA 1,0,0,0,6,0,7,0,0 90 DATA 0,4,0,0,0,0,0,3,0 100 ' 110 ' Create 2D array from data and count empty cells 120 ' 130 PRINT "Creating 2D array..." 140 DIM GP(8, 8) ' Game pattern 150 X = 0 160 Y = 0 170 EC = 0 ' Number of empty cells 180 FOR I = 0 TO 80 190 READ A 200 GP(X, Y) = A 210 IF A = 0 THEN EC = EC + 1 220 X = X + 1 230 IF X = 9 THEN X = 0 : Y = Y + 1 240 NEXT I 250 ' 260 ' Create empty cell lists 270 ' 280 PRINT "Creating empty cell lists..." 290 DIM EX(EC - 1) ' Empty cell X positions 300 DIM EY(EC - 1) ' Empty cell Y positions 310 PO = 0 320 FOR Y = 0 TO 8 330 FOR X = 0 TO 8 340 IF GP(X, Y) = 0 THEN EX(PO) = X : EY(PO) = Y : PO = PO + 1 350 NEXT X 360 NEXT Y 370 ' 380 ' Initialize solving loop 390 ' 400 PRINT : PRINT "Initiale solving loop..." 410 EP = 0 ' Empty cell pointer 420 MP = 0 ' Previous moves pointer 430 CI = 0 ' Candidate index pointer 440 DIM CL(9) ' Candidate array 450 DIM PI(EC) ' Previous move candidate index pointer array 460 ' 470 ' Start solving loop 480 ' 490 PRINT "Start solving loop..." 500 PRINT 510 IF EP > EC - 1 THEN GOSUB 1240 : END 520 X = EX(EP) ' Get x location for current empty cell 530 Y = EY(EP) ' Get y location for current empty cell 540 PRINT "Investigating"; X; ","; Y; "cIndex="; CI 550 ' Obtain candidates in cl array 560 GOSUB890 570 ' Check if there are candidates 580 IF CO > 0 THEN GOTO660 590 PRINTTAB(4) "Damn, there are no candidates at all!" 600 EP = EP - 1 610 MP = MP - 1 620 CI = PI(MP) + 1 630 GP(EX(EP),EY(EP)) = 0 640 GOTO 500 650 ' Check if we haven't tried all candidates 660 IF CO > CI THEN GOTO 740 670 PRINTTAB(4) "Fuck, we already tried all candidates!" 680 EP = EP - 1 690 MP = MP - 1 700 CI = PI(MP) + 1 710 GP(EX(EP),EY(EP)) = 0 720 GOTO 500 730 ' Ah, let's put the number on the board shall we 740 PRINTTAB(4) "Yes, add";CL(CI);"to x";X;",y";Y 750 GP(X,Y) = CL(CI) 760 ' Add this move to the previous moves lists 770 PI(MP) = CI 780 MP = MP + 1 790 ' Reset cIndex 800 CI = 0 810 ' Advance to the next cell 820 EP = EP + 1 830 ' Display the pattern 840 GOSUB 1240 850 GOTO 500 860 ' 870 ' Get all candidates for the specified cell 880 ' 890 PRINTTAB(4) "Obtain candidate list for";X;",";Y 900 FOR I = 0 TO 9 910 CL(I) = I 920 NEXT I 930 ' Apply region constraint 940 XX = (X \ 3) * 3 950 YY = (Y \ 3) * 3 960 FOR TY = YY TO YY + 2 970 FOR TX = XX TO XX + 2 980 IF GP(TX, TY) > 0 THEN CL(GP(TX, TY)) = 0 990 NEXT TX 1000 NEXT TY 1010 ' Apply row constraint 1020 FOR XX = 0 TO 8 1030 IF GP(XX, Y) > 0 THEN CL(GP(XX, Y)) = 0 1040 NEXT XX 1050 ' Apply column constraint 1060 FOR YY = 0 TO 8 1070 IF GP(X, YY) > 0 THEN CL(GP(X, YY)) = 0 1080 NEXT YY 1090 ' Sequence the cl array and count instances 1100 K = 0 ' Sequencing pointer 1110 CO = 0 ' Number of instances 1120 FOR I = 1 TO 9 1130 IF CL(I) > 0 THEN A=CL(I) : CL(I)=0 : CL(K)=A : K = K + 1 : CO = CO + 1 1140 NEXT I 1150 PRINTTAB(4) "Candidate list>>"; 1160 FOR I = 0 TO 9 1170 PRINT ;CL(I); 1180 NEXT I 1190 PRINT ;"Count:"; CO 1200 RETURN 1210 ' 1220 ' Print the entire game pattern 1230 ' 1240 FOR YY = 0 TO 8 1250 FOR XX = 0 TO 8 1260 PRINT;GP(XX,YY); 1270 NEXT XX 1280 PRINT 1290 NEXT YY 1300 RETURN

I think i will make it a bit more userfriendly and maybe it'll become a goodlooking program that does not say fuck or damn..

Well at least it works, the sudoku in the first data lines will finish in 285 iterations, it does 169 moves and 116 backtracks (28 No Candidate Errors and 88 All Candidates Tried errors resp DAMN and FUCK in the program).

have fun

but i doubt it