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 09:43, 11 September 2021
, 2 years agoAdd APL
Not a robot (talk | contribs) (Add APL) |
|||
Line 17:
one coin of 1
<br><br>
=={{header|APL}}==
{{works with|Dyalog APL}}
<lang APL>coins←{
{⍺,≢⍵}⌸⍺[⍒⍺]{
coin←⊃(⍵≥⍺)/⍺
coin=0:⍬
coin,⍺∇⍵-coin
}⍵
}</lang>
{{out}}
<pre> (1 2 5 10 20 50 100 200) coins 988
200 4
100 1
50 1
20 1
10 1
5 1
2 1
1 1</pre>
=={{header|AppleScript}}==
|