sudoku

Algorithm for solving Sudoku

和自甴很熟 提交于 2019-11-28 03:36:48
I want to write a code in python to solve a sudoku puzzle. Do you guys have any idea about a good algorithm for this purpose. I read somewhere in net about a algorithm which solves it by filling the whole box with all possible numbers, then inserts known values into the corresponding boxes.From the row and coloumn of known values the known value is removed.If you guys know any better algorithm than this please help me to write one. Also I am confused that how i should read the known values from the user. It is really hard to enter the values one by one through console. Any easy way for this

Algorithm Complexity (Big-O) of sudoku solver

主宰稳场 提交于 2019-11-28 03:24:17
问题 I'm look for the "how do you find it" because I have no idea how to approach finding the algorithm complexity of my program. I wrote a sudoku solver using java, without efficiency in mind (I wanted to try to make it work recursively, which i succeeded with!) Some background: my strategy employs backtracking to determine, for a given Sudoku puzzle, whether the puzzle only has one unique solution or not. So i basically read in a given puzzle, and solve it. Once i found one solution, i'm not

Sudoku backtracking algorithm

好久不见. 提交于 2019-11-27 13:21:11
First of all, I'll state that this is a university assignment so I'm not asking for someone to write the code for me I just need to be pointed in the right direction. :) Ok, so I need to write an algorithm to solve any (solvable) sudoku board of arbitrary size. I've written a recursive function that can solve any 9x9 board quickly (~1ms) but when I do larger boards (16x16) that are hard to solve it struggles.. I've had one test going for 20 minutes and it can't seem to solve it. It can solve easy 16x16 puzzles or even a blank 16x16 board so I don't think it's the dimensions that are the

Algorithm for solving Sudoku

扶醉桌前 提交于 2019-11-26 18:59:58
问题 I want to write a code in python to solve a sudoku puzzle. Do you guys have any idea about a good algorithm for this purpose. I read somewhere in net about a algorithm which solves it by filling the whole box with all possible numbers, then inserts known values into the corresponding boxes.From the row and coloumn of known values the known value is removed.If you guys know any better algorithm than this please help me to write one. Also I am confused that how i should read the known values

Sudoku backtracking algorithm

家住魔仙堡 提交于 2019-11-26 16:21:20
问题 First of all, I'll state that this is a university assignment so I'm not asking for someone to write the code for me I just need to be pointed in the right direction. :) Ok, so I need to write an algorithm to solve any (solvable) sudoku board of arbitrary size. I've written a recursive function that can solve any 9x9 board quickly (~1ms) but when I do larger boards (16x16) that are hard to solve it struggles.. I've had one test going for 20 minutes and it can't seem to solve it. It can solve

How to generate Sudoku boards with unique solutions

吃可爱长大的小学妹 提交于 2019-11-26 15:08:15
How do you generate a Sudoku board with a unique solution? What I thought was to initialize a random board and then remove some numbers. But my question is how do I maintain the uniqueness of a solution? TMS Easy: Find all solutions with an efficient backtracking algorithm. If there is just one solution, you are done. Otherwise if you have more than one solution, find a position at which most of the solutions differ. Add the number at this position. Go to 1. I doubt you can find a solution that would be much faster than this. Here is the way my own SuDoKu program does it: Start with a complete

How to generate Sudoku boards with unique solutions

拟墨画扇 提交于 2019-11-26 04:09:20
问题 How do you generate a Sudoku board with a unique solution? What I thought was to initialize a random board and then remove some numbers. But my question is how do I maintain the uniqueness of a solution? 回答1: Easy: Find all solutions with an efficient backtracking algorithm. If there is just one solution, you are done. Otherwise if you have more than one solution, find a position at which most of the solutions differ. Add the number at this position. Go to 1. I doubt you can find a solution

JFormattedTextField is not properly cleared

筅森魡賤 提交于 2019-11-26 00:13:29
问题 I am doing this assignment, make a program that solves sudoku. I have a panel with a grid of SudokuTextBox extends JFormattedTextField. I have a MaskFormatter so that it only accepts one integer per text box. Then in my panel I have this code when a key is relesed. public void keyReleased(KeyEvent e) { SudokuTextBox tb = (SudokuTextBox) e.getSource(); int row = tb.getRow(); int col = tb.getCol(); int value = toInteger(tb.getText()); //System.out.println(value); if(sudoku.isValid(row, col,

How to remove convexity defects in a Sudoku square?

若如初见. 提交于 2019-11-25 23:29:43
问题 I was doing a fun project: Solving a Sudoku from an input image using OpenCV (as in Google goggles etc). And I have completed the task, but at the end I found a little problem for which I came here. I did the programming using Python API of OpenCV 2.3.1. Below is what I did : Read the image Find the contours Select the one with maximum area, ( and also somewhat equivalent to square). Find the corner points. e.g. given below: ( Notice here that the green line correctly coincides with the true