Beispiel #1
0
        private static int StabilisationCount(char[,] grid, Func <int, int, char[, ], char> transformer)
        {
            var previousGrid = new char[grid.GetLength(0), grid.GetLength(1)];

            do
            {
                Array.Copy(grid, 0, previousGrid, 0, grid.Length);
                previousGrid.Transform(grid, transformer);
            } while (grid.Count('#') != previousGrid.Count('#') && grid.Count('L') != previousGrid.Count('L'));

            return(grid.Count('#'));
        }