public static void TargetCellStatusCheck(TargetCell cell) { if (cell.Value == 1) { cell.Counter++; } }
public static void Main() { var matrix = CreateAndFillZeroMatrix(); // Receiving the coordinates of the observed cell and how many generations will there be var additionalArguments = Console.ReadLine() .Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToArray(); // The coordinates of the cell to be checked var cellColumn = additionalArguments[0]; var cellRow = additionalArguments[1]; Cell cell = matrix.Find(c => c.Row == cellRow && c.Col == cellColumn); TargetCell targetCell = new TargetCell { Row = cell.Row, Col = cell.Col, Value = cell.Value }; // Check if cell is red or green in Generation Zero matrix TargetCellStatusCheck(targetCell); // The count of the new generations var lastGeneration = additionalArguments[2]; for (int generation = 0; generation < lastGeneration; generation++) { //The new matrix generation GenerateNewMatrix(matrix); // Check if cell is red or green in the new matrix targetCell.Value = matrix.Find(c => c.Row == targetCell.Row && c.Col == targetCell.Col).Value; TargetCellStatusCheck(targetCell); } //Count of changes of the target cell Console.WriteLine(targetCell.Counter); }