ways.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:07.0
disk size 651 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
%query: ways(i,i,o).
nat(0).
nat(s(X)):- nat(X).

plus(0,X,X) :- nat(X).
plus(s(X),Y,s(Z)) :- plus(X,Y,Z).


%     version with termination bug fixed

ways(0,_,s(0)).
ways(_,[],0).

ways(Amount,[s(C)|Coins],N) :-
    Amount=s(_),
    plus(s(C),NewAmount,Amount),
    ways(Amount,Coins,N1),
    ways(NewAmount,[s(C)|Coins],N2),
    plus(N1,N2,N).

ways(Amount,[s(C)|Coins],N) :-
    Amount=s(_),
    plus(Amount,s(_),s(C)),
    ways(Amount,Coins,N).



/*TWDESC

ways/3, the number of ways to change a given amount of money using a 
fixed set of coins values

*/

/*TWDEMO

selected_norms([termsize_edges]).
settings([cm=poly_mc,widenk=2]).
*/
/*.

*/
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark