Home‎ > ‎

### Meeting point Ciao

 main :-    board(Size),    MaxX = Size, MaxY = Size,    findall(number(X,Y,N),number(X,Y,N),Nums),    between(1,MaxX,MX),    between(1,MaxY,MY),    \+ member(number(MX,MY,_),Nums),    Visited = [],    route1(Nums,MX,MY,Visited,Plan),    output_links(Plan).route1([number(X,Y,N)|Nums],MX,MY,Visited,Plan) :-    \+ member((X,Y),Visited),        route2(X,Y,X,Y,N,MX,MY,[(X,Y)|Visited],Visited1,Plan,Plan1),    route1(Nums,MX,MY,Visited1,Plan1).route1([],_MX,_MY,_Visited,Plan) :- Plan=[].    route2(_PX,_PY,X,Y,N,X,Y,Visited,Visited1,Plan,PlanR) :- N=0, Plan=PlanR, Visited1=Visited.route2(PX,PY,X,Y,N,MX,MY,Visited,Visited1,Plan,PlanR) :-    Xm1 is X-1,    Xp1 is X+1,    Ym1 is Y-1,    Yp1 is Y+1,    member((X1,Y1),[(X,Ym1),(X,Yp1),(Xm1,Y),(Xp1,Y)]),        cell(X1,Y1),    \+ member((X1,Y1),Visited),    Plan = [link(X,Y,X1,Y1)|Plan1],    (X1\==PX, Y1\==PY ->        N1 is N-1,        N1 >= 0    ;        N1 = N    ),    ((X1,Y1) = (MX,MY) -> TmpVisited=Visited; TmpVisited = [(X1,Y1)|Visited]),    route2(X,Y,X1,Y1,N1,MX,MY,TmpVisited,Visited1,Plan1,PlanR).cell(X,Y) :-    board(N),    X >= 1, X =< N,    Y >= 1, Y =< N.    output_links([]).output_links([Link|L]) :-    write(Link),write('\n.'),    output_links(L).