I don't know why my code never passes through the second if
let knight_tour m n (x,y) (a,b) = if (m<1) || (n<1) || (not (is_in_board m n (a,b))) || (not (is_in_board m n (x,y))) || (a,b) = (x,y) then raise(Invalid_argument "knigth tour") else let rec aux pasos visited = function [] -> if pasos=m*n then List.rev visited else raise No_knigth_tour |h::t ->if pasos=m*n then try aux (pasos+1) (h::visited) (legal_moves m n h (a,b) (h::visited)) with No_knigth_tour -> aux pasos visited t else try aux (pasos+1) (h::visited) (legal_movesfin m n h (h::visited)) with No_knigth_tour -> aux pasos visited t in aux 1 [(x,y)] (legal_moves m n (x,y) (a,b) [(x,y)]);;
Aucun commentaire:
Enregistrer un commentaire