public void Go() { view.Clear(); view.Send("Welcome to Sudoku!"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (!game.IsFinished()) { view.Send("The current board state is:"); view.Send(game.ToString()); string input = view.Get("Enter the Value for the new cell and the 0 Based Index of the cell e.g. \"0,1\""); int[] inputParsed = Array.ConvertAll(input.Split(","), s => int.Parse(s)); int value = inputParsed[0]; int cell = inputParsed[1]; view.Clear(); view.Send($"Parsed Command => Value: {value} and Cell: {cell}"); view.Send(game.Play(value, cell)); view.Send($"you are now {stopwatch.Elapsed.TotalSeconds} seconds through the game"); } view.Send(game.ToString()); view.Send("Congrats! you finished the maze :D"); stopwatch.Stop(); view.Send($"It took you {stopwatch.Elapsed.TotalSeconds} seconds to complete the Sudoku!"); view.Finish(); }
public void SolveSudokuDialog(object sender, RoutedEventArgs e) { try { sudo = sudo.Solve(); string solvedString = Regex.Replace(sudo.ToString(), @"\t|\n|\r|\s", ""); InitializeSudoku(CreateArrayFromString(solvedString)); } catch { Stat.Text = "YOU NEED TO START A SUDOKU FIRST, MY N***A!"; } }
public void SaveSudokuDialog(object sender, RoutedEventArgs e) { string tmpSudokuString = Regex.Replace(sudo.ToString(), @"\t|\n|\r|\s", ""); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.DefaultExt = "txt"; if (saveFileDialog.ShowDialog() == true) { File.WriteAllText(saveFileDialog.FileName, tmpSudokuString); } }
public static string ToHumanString(this ISudoku sudoku) { return(sudoku.ToString().Replace('0', '.')); // ☐ }