Count the coins: Difference between revisions

Content added Content deleted
No edit summary
Line 277: Line 277:


=={{header|Arturo}}==
=={{header|Arturo}}==
<lang rebol>changes: function [amount coins][
{{trans|Python}}
ways: map 0..amount+1 [x]-> 0
<lang arturo>changes: @(amount coins){
ways: #(0)*(amount+1)
ways\0: 1
ways.0: 1


loop coins @(coin){
loop coins 'coin [
loop coin..amount @(j){
loop coin..amount 'j ->
ways.[j]: ways.[j]+ways.[j-coin]
set ways j (get ways j) + get ways j-coin
]
}
}
return ways.[amount]
}


ways \ amount
print [changes 100 #(1 5 10 25)]
]
print [changes 100000 #(1 5 10 25 50 100)]</lang>

print changes 100 [1 5 10 25]
{{out}}
print changes 100000 [1 5 10 25 50 100]</lang>

<pre>242
13398445413854501
</pre>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==