留学生代考 % In this problem, we use BFS to solve a coins puzzle

% In this problem, we use BFS to solve a coins puzzle

% Describe the coins puzzle using link(A,B)
% link(A,B) implies there there is an edge between A and B

Copyright By PowCoder代写 加微信 powcoder

% Think what we can use for A and B when we are dealing with
% the coins puzzle

path(Node,Node).
path(StartNode,EndNode) :-
link(StartNode,NextNode),
path(NextNode,EndNode).

path(Node,Node,[Node]).
path(StartNode,EndNode,[StartNode|Rest]) :-
link(StartNode,NextNode),
path(NextNode,EndNode,Rest).

list([_|L]):- list(L).

print([]).
print([H|T]) :- write(H), nl, print(T).

% force BFS and print results
coins :- list(Path),path([1,1,0,10,10],[10,10,0,1,1],Path), print(Path),!.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com