sudoku

How to get the cells of a sudoku grid with OpenCV?

ε祈祈猫儿з 提交于 2020-01-15 05:03:30
问题 I've been trying for the last few days to get a sudoku grid from a picture, and I have been struggling on getting the smaller squares of the grid. I am working on the picture below. I thought processing the image with a canny filter would work fine, but it didn't and I couldn't get every contour of each square. I then put adaptive threshold, otsu, and a classic thresholding to the test, but every time, it just could not seem to capture every small square. The final goal is to get the cells

Java sudoku generator not working correctly

僤鯓⒐⒋嵵緔 提交于 2020-01-13 15:46:36
问题 I have been working on a sudoku puzzle generator in java, I wrote this class to generate the puzzle but it is not correctly generating the puzzle. Here is an example of what I am getting: As you can see this is not a valid sudoku solution. But looking at my code, I don't understand why it is not generating a valid puzzle. Can someone explain why this does not work correctly? package sudoku; import java.util.Random; public class Puzzle { // number generator Random gen = new Random(); // 9x9

How to trace backtracks of clpfd in prolog?

自闭症网瘾萝莉.ら 提交于 2020-01-04 02:22:08
问题 I am making a sudoku solver with prolog using clpfd library . I have to trace the backtracks and every squares labeled with row and column and the number it gets in the following form: (1 ,1 ,1) (9 ,2 ,1) BT (5 ,2 ,1) My question is how can I get the above information from the algorithm? Another question: Does the algorithm observe arc-consistency rules by itself? 回答1: I don't think this is a particularly good idea, but here is something using SWI-Prolog's attributed variables that prints the

Finding characters in a string that occur only once

安稳与你 提交于 2020-01-02 07:43:08
问题 I'm writing an algorithm in PHP to solve a given Sudoku puzzle. I've set up a somewhat object-oriented implementation with two classes: a Square class for each individual tile on the 9x9 board, and a Sudoku class, which has a matrix of Square s to represent the board. The implementation of the algorithm I'm using is a sort of triple-tier approach. The first step, which will solve only the most basic puzzles (but is the most efficient), is to fill in any squares which can only take a single

How to prevent genetic algorithm from converging on local minima?

僤鯓⒐⒋嵵緔 提交于 2020-01-01 03:37:09
问题 I am trying to build a 4 x 4 sudoku solver by using the genetic algorithm. I have some issues with values converging to local minima. I am using a ranked approach and removing the bottom two ranked answer possibilities and replacing them with a crossover between the two highest ranked answer possibilities. For additional help avoiding local mininma, I am also using mutation. If an answer is not determined within a specific amount of generation, my population is filled with completely new and

Sudoku solver in Java, using backtracking and recursion

廉价感情. 提交于 2019-12-28 13:46:25
问题 I am programming a Sudoku solver in Java for a 9x9 grid. I have methods for: printing the grid initializing the board with given values testing for conflicts (if same number is in same line or 3x3 sub-grid) a method to place the digits, one by one, which requires the most work. Before I go into detail with that method, keep in mind that I have to use recursion to solve it, as well as backtracking (watch the applet here as an example http://www.heimetli.ch/ffh/simplifiedsudoku.html ) Also, I

Sudoku solver in c crashes

孤街浪徒 提交于 2019-12-25 18:33:54
问题 I am trying to figure out what is wrong with my code which is supposed to solve a 9x9 sudoku which crashes when I run it with the example in the Wikipedia for sudoku. I have also tried using recursion but am not very familiar with it so it did not work either. findunassignedlocation returns 1 if there are still 0s in the sudoku and 0 if there are no more 0s. isSafe returns 1 if all rows, columns and 3x3 grid does not contain the number and 0 otherwise. If the problem is probably in one of the

Sudoku box indices start position

为君一笑 提交于 2019-12-25 07:38:31
问题 I'm implementing a sudoku solver using backtracking. It reads a sudoku board in the form: 027800061000030008910005420500016030000970200070000096700000080006027000030480007 I know how I can figure the elements on a column by doing index % 9 (and then doing a simple arithmetic progression of ratio 9) as well the elements on a line by using index/9 (and then by adding one until I get every one of them), where index is a number in the range [0,80]. What I cannot figure out is how to get the

Recursive method for solving sudoku

£可爱£侵袭症+ 提交于 2019-12-23 01:41:41
问题 I'm currently studying my second programming course in java and have a problem with an assignment that I need to complete to pass the course. Basically it's about writing a program that recursively solves sudoku with backtracking. This is the algorithm I came up with. I used a 9x9 array to represent the grid which in the beginning is filled with zeroes. checkFill checks whether it's possible to insert a number (var) into a position[i][j]. The problem is that it only solves sudoku partially it

Recursive method for solving sudoku

眉间皱痕 提交于 2019-12-23 01:41:34
问题 I'm currently studying my second programming course in java and have a problem with an assignment that I need to complete to pass the course. Basically it's about writing a program that recursively solves sudoku with backtracking. This is the algorithm I came up with. I used a 9x9 array to represent the grid which in the beginning is filled with zeroes. checkFill checks whether it's possible to insert a number (var) into a position[i][j]. The problem is that it only solves sudoku partially it