Find minimum number of coins that make a given value: Difference between revisions
Content added Content deleted
(Added Lua) |
(Added Quackery.) |
||
Line 1,202: | Line 1,202: | ||
1 * 2 |
1 * 2 |
||
1 * 1</pre> |
1 * 1</pre> |
||
=={{header|Quackery}}== |
|||
<syntaxhighlight lang="Quackery"> [ ' [ 200 100 50 20 10 5 2 1 ] ] is coins ( --> [ ) |
|||
[ [] swap |
|||
coins witheach |
|||
[ /mod dip join ] |
|||
drop |
|||
witheach |
|||
[ dup 0 > iff |
|||
[ echo say " * " |
|||
coins i^ peek echo |
|||
cr ] |
|||
else drop ] ] is task ( n --> ) |
|||
' [ 988 345 1024 ] |
|||
witheach |
|||
[ say "To make " |
|||
dup echo say ":" cr |
|||
task cr ]</syntaxhighlight> |
|||
{{out}} |
|||
<pre>To make 988: |
|||
4 * 200 |
|||
1 * 100 |
|||
1 * 50 |
|||
1 * 20 |
|||
1 * 10 |
|||
1 * 5 |
|||
1 * 2 |
|||
1 * 1 |
|||
To make 345: |
|||
1 * 200 |
|||
1 * 100 |
|||
2 * 20 |
|||
1 * 5 |
|||
To make 1024: |
|||
5 * 200 |
|||
1 * 20 |
|||
2 * 2 |
|||
</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |