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 18:30, 16 December 2021
, 2 years agoAdded AutoHotkey
(Find minimum number of coins that make a given value en Yabasic) |
Alpha bravo (talk | contribs) (Added AutoHotkey) |
||
Line 181:
1 * 2
1 * 1</pre>
=={{header|AutoHotkey}}==
<lang AutoHotkey>coins := [1, 2, 5, 10, 20, 50, 100, 200]
val := 988
result := ""
while val
{
coin := coins.pop()
if (val//coin)
result .= val//coin " * " coin "`n", val -= val//coin * coin
}
MsgBox, 262144, , % result
return</lang>
{{out}}
<pre>4 * 200
1 * 100
1 * 50
1 * 20
1 * 10
1 * 5
1 * 2
1 * 1</pre>
=={{header|AWK}}==
<lang AWK>
|