// Test uniqueness private void btnTest_Click(object sender, System.EventArgs e) { Sudoku s = new Sudoku(); byte[,] d = GetData(); s.Data = d; tbHistory.AppendText("-------------------------------\r\n"); if (s.IsSudokuFeasible()) { tbHistory.AppendText("Sudoku feasible\r\n"); } else { tbHistory.AppendText("Sudoku not feasible\r\n"); } }
// Solve private void btnSolve_Click(object sender, System.EventArgs e) { Sudoku s = new Sudoku(); byte[,] d = GetData(); s.Data = d; tbHistory.AppendText("-------------------------------\r\n"); if (!s.IsSudokuFeasible()) { tbHistory.AppendText("Sudoku not feasible\r\n"); return; } DateTime now = DateTime.Now; tbHistory.AppendText("Solve started: " + now.ToLongTimeString() + "\r\n"); if (s.Solve()) { // Solve successful tbHistory.AppendText("Solve successful\r\n"); d = s.Data; SetData(d); } else { // Solve failed tbHistory.AppendText("Solve failed\r\n"); } tbHistory.AppendText(String.Format("{0} seconds\r\n", (DateTime.Now - now).TotalSeconds)); // Add blank tbHistory.AppendText("\r\n"); }
// Test uniqueness private void btnTest_Click(object sender, System.EventArgs e) { Sudoku s = new Sudoku(); byte[,] d = GetData(); s.Data = d; tbHistory.AppendText("-------------------------------\r\n"); if(s.IsSudokuFeasible()) { tbHistory.AppendText("Sudoku feasible\r\n"); } else { tbHistory.AppendText("Sudoku not feasible\r\n"); } }
public Game() { // // Required for Windows Form Designer support // InitializeComponent(); boxes = new ComboBox[9, 9]; Font font = null; for (int x = 0; x < 9; x++) { for (int y = 0; y < 9; y++) { ComboBox comboBox = new ComboBox(); if (font == null) { font = new Font(comboBox.Font, FontStyle.Bold); } comboBox.Font = font; String[] items = new String[] { "-", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; comboBox.Items.AddRange(items); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(x * 40 + 10, y * 30 + 10); comboBox.Size = new Size(36, 21); comboBox.SelectedIndex = 0; comboBox.MaxDropDownItems = 10; this.Controls.Add(comboBox); boxes[y, x] = comboBox; } } Sudoku s = new Sudoku(); byte[,] d = s.read_from_file(); /* * * tbHistory.AppendText("-------------------------------\r\n"); * if(!s.IsSudokuFeasible()) * {// * tbHistory.AppendText("Sudoku not feasible\r\n"); * return; * } * * DateTime now = DateTime.Now; * tbHistory.AppendText("Solve started: " + now.ToLongTimeString() + "\r\n"); * * if(s.Solve()) * { * // Solve successful * tbHistory.AppendText("Solve successful\r\n"); * * d = s.Data; * SetData(d); * } * else * { * // Solve failed * tbHistory.AppendText("Solve failed\r\n"); * } * tbHistory.AppendText(String.Format("{0} seconds\r\n", (DateTime.Now - now).TotalSeconds)); * * // Add blank * tbHistory.AppendText("\r\n"); */ SetData(d); s.Data = d; if (!s.IsSudokuFeasible()) {// tbHistory.AppendText("Sudoku not feasible\r\n"); return; } if (s.Solve()) { // Solve successful tbHistory.AppendText("Solve successful\r\n"); d = s.Data; SetData(d); } else { // Solve failed tbHistory.AppendText("Solve failed\r\n"); } m_printDocument = new PrintDocument(); m_printDocument.PrintPage += new PrintPageEventHandler(PrintPage); }
// Solve private void btnSolve_Click(object sender, System.EventArgs e) { Sudoku s = new Sudoku(); byte[,] d = GetData(); s.Data = d; tbHistory.AppendText("-------------------------------\r\n"); if(!s.IsSudokuFeasible()) { tbHistory.AppendText("Sudoku not feasible\r\n"); return; } DateTime now = DateTime.Now; tbHistory.AppendText("Solve started: " + now.ToLongTimeString() + "\r\n"); if(s.Solve()) { // Solve successful tbHistory.AppendText("Solve successful\r\n"); d = s.Data; SetData(d); } else { // Solve failed tbHistory.AppendText("Solve failed\r\n"); } tbHistory.AppendText(String.Format("{0} seconds\r\n", (DateTime.Now - now).TotalSeconds)); // Add blank tbHistory.AppendText("\r\n"); }