示例#1
0
        public (string, string[, ]) ConvertPuzzleFileToSearchWordsAndGrid(string filePath)
        {
            string[] fileRows = _fileOperations.ReadLines(filePath);

            var searchStrings = fileRows[0];
            var gridRows      = fileRows.Skip(1).ToArray();

            string[,] grid = new string[gridRows[0].Count(o => o == ',') + 1, gridRows.Count()];

            int columnCount;
            int rowCount = 0;

            foreach (var row in gridRows)
            {
                string[] rowChars = row.Split(',');
                columnCount = 0;
                foreach (var rowChar in rowChars)
                {
                    grid[rowCount, columnCount] = rowChar;
                    columnCount++;
                }
                rowCount++;
            }

            return(searchStrings, grid);
        }