Anonymous user
Count the coins: Difference between revisions
Updated second D entry
(Updated third D entry) |
(Updated second D entry) |
||
Line 366:
<lang d>import std.stdio, std.bigint;
BigInt countChanges(in int amount, in int[] coins)
immutable
int cycle;
foreach (
if (c <= amount && c >= cycle)
cycle = c + 1;
cycle *= n;
auto table = new BigInt[cycle];
table[0 .. n] =
int pos = n;
foreach (immutable s; 1 .. amount + 1) {
foreach (immutable i; 0 .. n) {
if (i == 0 && pos >= cycle)
pos = 0;
Line 398:
immutable euCoins = [200, 100, 50, 20, 10, 5, 2, 1];
foreach (immutable coins; [usCoins, euCoins]) {
writeln;
}
}</lang>
|