Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
suduko solver
//fpc 2.6.2 // suduku solver program suduko_solver; uses SysUtils; const dolzina = 9; type sudukoArray = array[1..dolzina] of Integer; sudukoArrayMulti = array[1..dolzina] of sudukoArray; procedure initFillZero(s: sudukoArrayMulti); var i, j: integer; begin i := 1; j := 1; while (i <= 9) do begin j := 1; while (j <= 9) do begin s[i,j] := 0; Inc(j); end; Inc(i); end; end; procedure initHelper(s: sudukoArrayMulti); var i, j: integer; begin for i:= 0 to 8 do begin for j:= 0 to 8 do begin writeln('s['+IntToStr(i+1)+','+IntToStr(j+1)+'] := 0;'); end; writeln(''); end; end; function initFillNumbers():sudukoArrayMulti; var s: sudukoArrayMulti; begin // dejanski init (popravi vrednosti) s[1,1] := 0; s[1,2] := 7; s[1,3] := 0; s[1,4] := 1; s[1,5] := 0; s[1,6] := 0; s[1,7] := 0; s[1,8] := 0; s[1,9] := 0; s[2,1] := 5; s[2,2] := 0; s[2,3] := 0; s[2,4] := 2; s[2,5] := 0; s[2,6] := 4; s[2,7] := 0; s[2,8] := 1; s[2,9] := 0; s[3,1] := 0; s[3,2] := 0; s[3,3] := 0; s[3,4] := 0; s[3,5] := 0; s[3,6] := 3; s[3,7] := 0; s[3,8] := 0; s[3,9] := 8; s[4,1] := 7; s[4,2] := 9; s[4,3] := 0; s[4,4] := 6; s[4,5] := 4; s[4,6] := 0; s[4,7] := 0; s[4,8] := 0; s[4,9] := 5; s[5,1] := 0; s[5,2] := 0; s[5,3] := 1; s[5,4] := 0; s[5,5] := 0; s[5,6] := 0; s[5,7] := 2; s[5,8] := 0; s[5,9] := 0; s[6,1] := 6; s[6,2] := 0; s[6,3] := 0; s[6,4] := 0; s[6,5] := 1; s[6,6] := 8; s[6,7] := 0; s[6,8] := 3; s[6,9] := 9; s[7,1] := 9; s[7,2] := 0; s[7,3] := 0; s[7,4] := 8; s[7,5] := 0; s[7,6] := 0; s[7,7] := 0; s[7,8] := 0; s[7,9] := 0; s[8,1] := 0; s[8,2] := 2; s[8,3] := 0; s[8,4] := 9; s[8,5] := 0; s[8,6] := 1; s[8,7] := 0; s[8,8] := 0; s[8,9] := 4; s[9,1] := 0; s[9,2] := 0; s[9,3] := 0; s[9,4] := 0; s[9,5] := 0; s[9,6] := 6; s[9,7] := 0; s[9,8] := 5; s[9,9] := 0; initFillNumbers := s; end; procedure printSuduko(s: sudukoArrayMulti); var i, j: integer; begin //kontrola for i:= 0 to 8 do begin for j:= 0 to 8 do begin write(IntToStr(s[i+1,j+1])+' '); if ((j+1) mod 3 = 0) then write('| '); end; writeln(''); if ((i+1) mod 3 = 0) then writeln('- - - + - - - + - - - +'); end; end; function checkZero(s: sudukoArrayMulti): Boolean; label konec; var i, j: integer; ret: Boolean; begin i := 1; ret := true; // na začetku sklepam da je rešen while (i <= 9) do begin j := 1; while (j <= 9) do begin if (s[i,j] = 0) then begin ret := false; //ko najde prvega z 0 zaključi - ni rešen! goto konec; end; Inc(j); end; Inc(i); end; konec: checkZero := ret; end; // deklaracija variabel var i,j: integer; s: sudukoArrayMulti; test: Boolean; begin //initFillZero(s); //initHelper(s); s := initFillNumbers(); //printSuduko(s); //writeln(BooltoStr(checkZero(s))); end.
run
|
edit
|
history
|
help
0
BubbleSor (slimmer)
Record as a procedure argument
practica 7 ejercicio 3
basketball_player_training
For7
lala
test22
444555666_final_version
eliminar elemento de un arreglo
ahoj