Example #1
0
        static void Main()
        {
            // get initial input data
            string[] startLocation = Console.ReadLine().Split(' ');
            int startingRow = int.Parse(startLocation[0]);
            int startingCol = int.Parse(startLocation[1]);

            string[] matrixSize = Console.ReadLine().Split(' ');
            int rows = int.Parse(matrixSize[0]);
            int cols = int.Parse(matrixSize[1]);

            // fill matrix
            string[,] matrix = new string[rows, cols];
            for (int row = 0; row < rows; row++)
            {
                string[] rowElements = Console.ReadLine().Split(' ');
                for (int col = 0; col < cols; col++)
                {
                    matrix[row, col] = rowElements[col];
                }
            }

            Cell startCell = new Cell(matrix[startingRow, startingCol], startingRow, startingCol);
            Tree tree = new Tree(new TreeNode(int.Parse(startCell.Value), startingRow, startingCol));
        }
Example #2
0
        public Tree TraverseTree(Tree tree, TreeNode startCell, string[,] matrix)
        {
            foreach (TreeNode child in startCell.GetChildren())
            {
                Cell currentCell = new Cell(child.Value.ToString(), child.Row, child.Col);
                IEnumerable<Cell> cellsInRange = GetCellsInRange(currentCell, matrix);
                foreach (Cell cell in cellsInRange)
                {

                }
            }

            return tree;
        }