Percolation/Site percolation: Difference between revisions

Simpler grid printing in the D entry (as the Racket version)
(=={{header|Racket}}== implementation added)
(Simpler grid printing in the D entry (as the Racket version))
Line 199:
 
void show(in ref Grid grid) {
immutable static line = '+' ~ "-".replicate(nCols) ~ "+";
line.writeln;
foreach (const ref row; grid)
writeln('|', cast(BaseType[nCols])row, '|');
line.writeln;
}
 
Line 284 ⟶ 281:
{{out}}
<pre>Percolating sample (15x15, probability = 0.30):
|#..##.###### ...## ##|
+---------------+
|..####. ##..#.# #|
|.# ## ### ##..#. #|
|## ### ## ###.# ##|
|### ## ### #.### |
|## ### ### #..# #|
|## #### # ###.##. |
|# #########. ###.#|
| ## # ### #.# #.. |
|## # ### # #.###|
| # # # ###### #.. # |
|# ## #### #. ##. |
| ## # ## # #.##..#|
| #### #### #. .##|
|## # ###### #.. # #|
|######### .####|
+---------------+
 
Fraction of 20000 tries that percolate through:
Line 307 ⟶ 302:
0.200 0.000
0.300 0.000
0.400 0.004003
0.500 0.090094
0.600 0.561570
0.700 0.958956
0.800 1.000
0.900 1.000