sudoku

Sudoku algorithm, brute force [closed]

巧了我就是萌 提交于 2019-12-01 14:24:14
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . Iam trying to solve a sudoku board with a brute force algorithm, I cant really get this algorithm work correctly. There is created a object for each row,

Sudoku solving in c++

耗尽温柔 提交于 2019-12-01 14:21:19
I've recently been working on a sudoku game in c++. I've made a graphic version of it using SFML and it works just fine. However, I need to implement an algorithm which will solve the sudoku, whilst not being a brute-force algorithm (so backtracking doesn't work for me ;/). I've read about many ways to solve it and I've come across different algorithm names (such as Dancing Links), as well as algorithms which only describe how the search works without giving any specific pieces of information on how to implement it in c++. (i.e. assigning a table or a list of possible numbers to each single

Sudoku solver in python using backtracking

女生的网名这么多〃 提交于 2019-12-01 13:29:30
问题 I saw a few sudoku solvers implementations ,but I cant figure out the problem in my code. I have a function sudokusolver which becomes sudoku Board and must return solved sudoku board. def sudokutest(s,i,j,z): # z is the number isiValid = np.logical_or((i+1<1),(i+1>9)); isjValid = np.logical_or((j+1<1),(j+1>9)); iszValid = np.logical_or((z<1),(z>9)); if s.shape!=(9,9): raise(Exception("Sudokumatrix not valid")); if isiValid: raise(Exception("i not valid")); if isjValid: raise(Exception("j not

Sudoku solving in c++

你。 提交于 2019-12-01 12:36:19
问题 I've recently been working on a sudoku game in c++. I've made a graphic version of it using SFML and it works just fine. However, I need to implement an algorithm which will solve the sudoku, whilst not being a brute-force algorithm (so backtracking doesn't work for me ;/). I've read about many ways to solve it and I've come across different algorithm names (such as Dancing Links), as well as algorithms which only describe how the search works without giving any specific pieces of information

Generating minimal/irreducible Sudokus

心已入冬 提交于 2019-11-30 20:41:09
A Sudoku puzzle is minimal (also called irreducible) if it has a unique solution, but removing any digit would yield a puzzle with multiple solutions. In other words, every digit is necessary to determine the solution. I have a basic algorithm to generate minimal Sudokus: Generate a completed puzzle. Visit each cell in a random order. For each visited cell: Tentatively remove its digit Solve the puzzle twice using a recursive backtracking algorithm. One solver tries the digits 1-9 in forward order, the other in reverse order. In a sense, the solvers are traversing a search tree containing all

Programming Design Help - How to Structure a Sudoku Solver program? [closed]

狂风中的少年 提交于 2019-11-30 10:37:11
I'm trying to create a sudoku solver program in Java (maybe Python). I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? Thanks. Don't

Why is translated Sudoku solver slower than original?

让人想犯罪 __ 提交于 2019-11-30 10:07:14
问题 I transcribed my Java Sudoku solver into python. Everything works, however solving takes up to 2mins, while the identical puzzle takes only a few seconds in Java. Also the iterations needed amount to the exact same number. Am I missing something? import numpy as np def solve_recursive(puzzle, pos): if(pos == 81): print puzzle return True if(puzzle[pos] != 0): if (not solve_recursive(puzzle, pos+1)): return False else: return True row = np.copy(puzzle[pos//9*9:pos//9*9+9]) col = np.copy(puzzle

Building a GUI for a Sudoku Solver (Complete with ASCII Example)

两盒软妹~` 提交于 2019-11-30 06:42:10
. OVERVIEW, SAMPLE Hello everyone, I have created a basic Sudoku solver that can solve most problems fairly quickly. I still have a lot of work ahead of me to make it solve even the hardest problems, but I'd like to try to implement a basic JFrame GUI first. I have worked with internet applets in the past, but never before with JFrames. I want to create something similar to the image below (for starters): ------------------------------------------------------------------------------------------------- ! Sudoku Solver 1.0 - [] X ! ----------------------------------------------------------------

Generating minimal/irreducible Sudokus

雨燕双飞 提交于 2019-11-30 04:49:28
问题 A Sudoku puzzle is minimal (also called irreducible) if it has a unique solution, but removing any digit would yield a puzzle with multiple solutions. In other words, every digit is necessary to determine the solution. I have a basic algorithm to generate minimal Sudokus: Generate a completed puzzle. Visit each cell in a random order. For each visited cell: Tentatively remove its digit Solve the puzzle twice using a recursive backtracking algorithm. One solver tries the digits 1-9 in forward

Sudoku validity check algorithm - how does this code works?

徘徊边缘 提交于 2019-11-30 01:50:20
I was reading a question posted here: Sudoku algorithm in C# And one of the solutions posted was this piece of code. public static bool IsValid(int[] values) { int flag = 0; foreach (int value in values) { if (value != 0) { int bit = 1 << value; if ((flag & bit) != 0) return false; flag |= bit; } } return true; } The idea is that it will detect duplicates in the array of values; but I'm overwhelmed by how much I don't know. Can someone explain this to me? EDIT: Thanks everyone. So many great answers, I don't know how to select one. It now makes perfect sense. Really a nice idea. Basically, it