Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/Count-the-coins/Mathematica/count-the-coins.math
Normal file
8
Task/Count-the-coins/Mathematica/count-the-coins.math
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CountCoins[amount_, coinlist_] := ( ways = ConstantArray[1, amount];
|
||||
Do[For[j = coin, j <= amount, j++,
|
||||
If[ j - coin == 0,
|
||||
ways[[j]] ++,
|
||||
ways[[j]] += ways[[j - coin]]
|
||||
]]
|
||||
, {coin, coinlist}];
|
||||
ways[[amount]])
|
||||
Loading…
Add table
Add a link
Reference in a new issue