Percolation/Bond percolation: Difference between revisions
Content added Content deleted
(Fixed performance problem in the D entry.) |
(Updated D entry) |
||
Line 266: | Line 266: | ||
nr, nc, nTries); |
nr, nc, nTries); |
||
foreach (immutable p; 0 .. nStepsProb) { |
foreach (immutable p; 0 .. nStepsProb) { |
||
immutable probability = p / |
immutable probability = p / double(nStepsProb); |
||
uint nPercolated = 0; |
uint nPercolated = 0; |
||
foreach (immutable i; 0 .. nTries) { |
foreach (immutable i; 0 .. nTries) { |
||
Line 273: | Line 273: | ||
} |
} |
||
writefln("p = %0.2f: %.4f", |
writefln("p = %0.2f: %.4f", |
||
probability, nPercolated / |
probability, nPercolated / double(nTries)); |
||
} |
} |
||
}</lang> |
}</lang> |