Find minimum number of coins that make a given value: Difference between revisions
Find minimum number of coins that make a given value (view source)
Revision as of 02:48, 9 August 2021
, 2 years agoAdd Factor
m (→{{header|Julia}}: typo) |
(Add Factor) |
||
Line 15:
<br><br>
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: assocs kernel math math.order prettyprint sorting ;
: make-change ( value coins -- assoc )
[ >=< ] sort [ /mod swap ] zip-with nip ;
988 { 1 2 5 10 20 50 100 200 } make-change .</lang>
{{out}}
<pre>
{
{ 200 4 }
{ 100 1 }
{ 50 1 }
{ 20 1 }
{ 10 1 }
{ 5 1 }
{ 2 1 }
{ 1 1 }
}
</pre>
=={{header|Julia}}==
|