Count the coins/0-1: Difference between revisions
m
→{{header|Wren}}: Minor changes.
(Realize in MiniZinc) |
m (→{{header|Wren}}: Minor changes.) |
||
Line 317:
import "/math" for Int
var cnt
var cnt2
var wdth
var count // recursive
Line 338:
var countCoins = Fn.new { |want, coins, width|
System.print("Sum %(want) from coins %(coins)")
cnt = 0
cnt2 = 0
Line 357:
{{out}}
<pre>
Sum 6 from coins [1, 2, 3, 4, 5]
indices [0, 1, 2] => used [1, 2, 3]
indices [0, 4] => used [1, 5]
Line 364:
Number of ways - order important : 10 (all perms of above indices)
Sum 6 from coins [1, 1, 2, 3, 3, 4, 5]
indices [0, 1, 5] => used [1, 1, 4]
indices [0, 2, 3] => used [1, 2, 3]
Line 377:
Number of ways - order important : 38 (all perms of above indices)
Sum 40 from coins [1, 2, 3, 4, 5, 5, 5, 5, 15, 15, 10, 10, 10, 10, 25, 100]
indices [0, 1, 2, 3, 4, 5, 6, 7, 10] => used [1, 2, 3, 4, 5, 5, 5, 5, 10]
indices [0, 1, 2, 3, 4, 5, 6, 7, 11] => used [1, 2, 3, 4, 5, 5, 5, 5, 10]
|