Skip to content

Instantly share code, notes, and snippets.

@thaenor
Created January 31, 2015 15:34
Show Gist options
  • Save thaenor/72fbe853cf57afe97c8c to your computer and use it in GitHub Desktop.
Save thaenor/72fbe853cf57afe97c8c to your computer and use it in GitHub Desktop.
Grupo 1 - ex1 - Exame ALGAV 3-Fev-2014
dstPosto(pt1,pt2,21).
dstPosto(pt3,pt4,55).
dstPosto(pt5,pt3,30).
dstPosto(pt2,pt5,19).
dstPosto(pt4,pt2,13).
dstPosto(pt1,pt6,28).
abstrobot(r1, [pt4, pt5, pt2, pt6, pt5]).
abstrobot(r2, [pt1, pt3, pt6]).
abstrobot(r3, [pt2, pt5, pt3, pt2, pt6, pt1, pt5]).
abstrobot(_,[]).
abstPosto(P,L):-
abstrobot(R,Caminho),
member(P,Caminho),
contaPassagens(P,Caminho,N),
write('Robot '), write(R), write(' passa no posto '),write(P), write(N), write('vezes').
contaPassagens(_,[],_).
contaPassagens(P,[H|T],N):-
P == H,
N1 is N+1,
contaPassagens(P,T,N1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment