Re: Change for a Dollar



"Charles Richmond" <frizzle@xxxxxxxxx> a écrit dans le message de news:
462E4A7F.4060205@xxxxxxxxxxxx
I heard one night on David Letterman that there are
293 ways to make change for a dollar. So I started
thinking about writing a program to list out *all*
the ways a dollar could be broken into change. I
just can *not* seem to get a hold on this problem.

I wrote a program with a recursive function attempting
to make the change, but it had excessive runtime and
does *not* seem to be working in any case...
Does anyone have an idea how I can proceed???

One way to do this is to use a dynamic programming approach. An
implementation in Prolog can be found at
http://perso.orange.fr/colin.barker/lpa/change.htm.
--
Colin


.



Relevant Pages