Find minimum number of coins that make a given value: Difference between revisions

added Arturo
(added Arturo)
Line 206:
1 * 2
1 * 1</pre>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">coins: [200 100 50 20 10 5 2 1]
target: 988
 
print ["Minimum number of coins to make a value of " (to :string target)++":"]
 
cnt: 0
remaining: new target
 
loop coins 'coin [
n: remaining / coin
if not? zero? n [
cnt: cnt + n
print [" coins of" coin "->" n]
remaining: remaining - n * coin
if zero? remaining -> break
]
]
 
print ["\nTotal: " cnt]</syntaxhighlight>
 
{{out}}
 
<pre>Minimum number of coins to make a value of 988:
coins of 200 -> 4
coins of 100 -> 1
coins of 50 -> 1
coins of 20 -> 1
coins of 10 -> 1
coins of 5 -> 1
coins of 2 -> 1
coins of 1 -> 1
 
Total: 11</pre>
 
=={{header|AutoHotkey}}==
1,532

edits