private ISudokuPuzzle ParsePuzzle2(string source) { ISudokuPuzzle puzzle; ISudokuPosition currentPosition = new SudokuPosition(); string[] rows = source.Split(DELIMITER_ROW); string[] cols; puzzle = new SudokuPuzzle((int)Math.Sqrt(rows.Length)); for (int i = 0; i < rows.Length; i++) { currentPosition.RowNumber = i; cols = rows[i].Split(DELIMITER_COL); for (int j = 0; j < cols.Length; j++) { currentPosition.ColumnNumber = j; puzzle.SetValue(currentPosition, Int32.Parse(cols[j].ToString())); } } return puzzle; }
private ISudokuPuzzle ParseInputPuzzleFromForm() { ISudokuPuzzle puzzle = new SudokuPuzzle(PUZZLE_SIZE); ISudokuPosition currentPosition = new SudokuPosition(); foreach (string key in Request.Form.AllKeys) { int trash; // Dummy variable if(Int32.TryParse(key.Substring(0, 1), out trash)) { string[] row_col = key.Split('_'); currentPosition.RowNumber = Int32.Parse(row_col[0]); currentPosition.ColumnNumber = Int32.Parse(row_col[1]); int value = Int32.Parse(Request.Form[key]); puzzle.SetValue(currentPosition, value); } } return puzzle; }