home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.prolog
- Path: sparky!uunet!mcsun!Germany.EU.net!ecrc!acrab60!thom
- From: thom@ecrc.de (Thom Fruehwirth)
- Subject: British coinage problem
- Message-ID: <1993Jan7.141322.22240@ecrc.de>
- Keywords: Keep simple problems simple
- Sender: news@ecrc.de
- Reply-To: thom@ecrc.de
- Organization: European Computer-Industry Research Centre GmbH.
- Date: Thu, 7 Jan 1993 14:13:22 GMT
- Lines: 22
-
- min_coins(Value,Coins):- list(Coins),sum_coins(Coins,Value).
-
- list([]).
- list([X|L]):- list(L).
-
- sum_coins([],0).
- sum_coins([Coin|Coins],Sum):-
- coin(Coin,Value),
- Value =< Sum,
- NewSum is Sum-Value,
- sum_coins(Coins,NewSum).
-
- coin('ten shilling note', 120).
- coin( 'half-crown', 30).
- coin( 'florin', 24).
- coin( 'shilling', 12).
- coin( 'sixpence', 6).
- coin( 'threepenny bit', 3).
- coin( 'penny', 1).
-
- % thom
-
-