(rows: number, cols: number, probability: number = 0.3)
| 1 | export const createGrid = (rows: number, cols: number, probability: number = 0.3): boolean[][] => { |
| 2 | const grid: boolean[][] = []; |
| 3 | for (let y = 0; y < rows; y++) { |
| 4 | grid[y] = []; |
| 5 | for (let x = 0; x < cols; x++) { |
| 6 | grid[y][x] = Math.random() < probability; |
| 7 | } |
| 8 | } |
| 9 | return grid; |
| 10 | }; |
| 11 | |
| 12 | export const countNeighbors = (grid: boolean[][], x: number, y: number, rows: number, cols: number): number => { |
| 13 | let count = 0; |
no outgoing calls
no test coverage detected