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

Added solution for Action!
(added AWK)
(Added solution for Action!)
Line 17:
one coin of 1
<br><br>
 
=={{header|Action!}}==
<lang Action!>PROC Main()
DEFINE LEN="8"
BYTE ARRAY coins=[200 100 50 20 10 5 2 1],count(LEN)
BYTE i
INT value=[988],curr,total
 
Zero(count,LEN)
i=0 total=0
curr=value
WHILE curr>0
DO
IF curr>=coins(i) THEN
count(i)==+1
total==+1
curr==-coins(i)
ELSE
i==+1
FI
OD
 
PrintF("%I coins to make %I:%E",total,value)
FOR i=0 TO LEN-1
DO
IF count(i) THEN
PrintF(" %B x %B%E",count(i),coins(i))
FI
OD
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Find_minimum_number_of_coins_that_make_a_given_value.png Screenshot from Atari 8-bit computer]
<pre>
11 coins to make 988:
4 x 200
1 x 100
1 x 50
1 x 20
1 x 10
1 x 5
1 x 2
1 x 1
</pre>
 
=={{header|APL}}==
Anonymous user