Discussione: piccola sfida
View Single Post
Old 18-11-2003, 10:27   #78
bsummer
Senior Member
 
L'Avatar di bsummer
 
Iscritto dal: Oct 2002
Messaggi: 487
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...

Ultima modifica di bsummer : 18-11-2003 alle 13:10.
bsummer č offline   Rispondi citando il messaggio o parte di esso