Scritto in pseudo c-codice
Codice:
int r,c;
boolean path_finder(*matrice, ar,ac,n) {
if (ar<0)||(ar>=r)||(ac<0)||(ac>=c)||(matrice(r,c)==0) then {
return false;
} else {
matrice(r,c) =n
if n = 100 then return true;
tmp = path_finder(matrice,ar-2,ac-2,n+1);
if tmp ==false then tmp= path_finder(matrice,ar-3,ac,n+1);
if tmp ==false then tmp= path_finder(matrice,ar-2,ac+2,n+1);
if tmp ==false then tmp= path_finder(matrice,ar,ac+3,n+1);
if tmp ==false then tmp= path_finder(matrice,ar+2,ac+2,n+1);
if tmp ==false then tmp= path_finder(matrice,ar+3,ac,n+1);
if tmp ==false then tmp= path_finder(matrice,ar+2,ac-2,n+1);
if tmp ==false then tmp= path_finder(matrice,ar,ac-3,n+1);
return tmp
}
}
Potrebbe andare? Cosė ad occhio credo di si e penso funzioni pure con matrici non quadrate.
Boh...