(String[] args)
| 91 | } |
| 92 | |
| 93 | public static void main(String[] args) { |
| 94 | int n = StdIn.readInt(); |
| 95 | Percolation p = new Percolation(n); |
| 96 | while (!p.percolates()) { |
| 97 | for (int row = 1; row <= n; row++) |
| 98 | for (int col = 1; col <= n; col++) { |
| 99 | if (!p.isOpen(row, col)) |
| 100 | if (StdRandom.bernoulli(1.0 / (n * n - p.numberOfOpenSites()))) |
| 101 | p.open(row, col); |
| 102 | } |
| 103 | } |
| 104 | StdOut.println("Percolation threshold is " + p.numberOfOpenSites() / Math.pow(n, 2)); |
| 105 | } |
| 106 | } |
nothing calls this directly
no test coverage detected