public static Csp FromFile(SudokuSettings settings) { var fileAsStrings = File.ReadAllLines(Path.Combine(Environment.CurrentDirectory, "Sudoku.csv")).Skip(1) .ToList(); return(new Csp(fileAsStrings, settings)); }
private Csp(IEnumerable <string> fileAsStrings, SudokuSettings settings) { Settings = settings; Sudokus = fileAsStrings.Select(boardAsString => { var board = new int[9, 9]; var unparsedBoard = boardAsString.Split(";")[2]; var counter = 0; for (var i = 0; i < 9; i++) { for (var j = 0; j < 9; j++) { board[i, j] = (int)char.GetNumericValue(unparsedBoard[counter]); if (board[i, j] == -1) { board[i, j] = 0; } counter++; } } return(new Sudoku(board, ParseVariableSelection(), ParseValueSelection())); }).ToList(); }
public SudokuSolver(Sudoku firstSudoku, SudokuSettings settings) { Settings = settings; Result = new SudokuResult(); FirstSudoku = firstSudoku; Solutions = new List <Sudoku>(); Algorithm = ParseAlgorithm(); ValueSelection = ParseValueSelection(); VariableSelection = ParseVariableSelection(); }