path(Z, Z).
path(X, Y) :- move(X, W), not(been(W)), assert(been(W)), path(W, Y).

move(a, b).
move(b, a).
move(a, c).
move(c, d).
move(a, e).
move(d, f).

path(Z, Z, _).
path(X, Y, L) :- move(X, W), not(member(W, L)), path(W, Y, [W|L]).

