Count the coins: Difference between revisions
Content added Content deleted
(Added Tailspin solution) |
|||
Line 3,039: | Line 3,039: | ||
99341140660285639188927260001 |
99341140660285639188927260001 |
||
992198221207406412424859964272600001</pre> |
992198221207406412424859964272600001</pre> |
||
=={{header|Tailspin}}== |
|||
{{trans|Rust}} |
|||
<lang tailspin> |
|||
templates makeChange&{coins:} |
|||
def paid: $; |
|||
@: [1..$paid -> 0]; |
|||
$coins... -> \(def coin: $; |
|||
@makeChange($coin): $@makeChange($coin) + 1; |
|||
$coin+1..$paid -> @makeChange($): $@makeChange($) + $@makeChange($-$coin); |
|||
\) -> !VOID |
|||
$@($paid)! |
|||
end makeChange |
|||
100 -> makeChange&{coins: [1,5,10,25]} -> '$; ways to change a dollar |
|||
' -> !OUT::write |
|||
100000 -> makeChange&{coins: [1,5,10,25,50,100]} -> '$; ways to change 1000 dollars with all coins |
|||
' -> !OUT::write |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
242 ways to change a dollar |
|||
13398445413854501 ways to change 1000 dollars with all coins |
|||
</pre> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |