Questions tagged [sudoku]
Sudoku (soo-doh-koo) is a number-placement logic puzzle. The objective is to fill a partially constructed 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid contain all of the digits from 1 to 9.
1,142
questions
1
vote
1
answer
43
views
Im trying to make a sudoku puzzle in javascript but it wont work:(
let grid = [[2, 5, 0, 0, 3, 0, 9, 0, 1],
[0, 1, 0, 0, 0, 4, 0, 0, 0],
[4, 0, 7, 0, 0, 0, 2, 0, 8],
[0, 0, 5, 2, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 9, 8, 1, 0, 0],
[0, 4, 0, 0, 0, 3, 0, 0, 0],
[0, 0, 0, 3, 6,...
0
votes
1
answer
38
views
JavaScript Sudoku grid generation doesn't execute all the way
So I've been trying to generate a solved sudoku grid in JavaScript for a while now.
I now have a version that runs smoothly until a certain (always different) point.
I don't get any errors but at some ...
-1
votes
0
answers
27
views
Binary sudoku grid generation
I am making a playable binary sudoku game for the terminal with node, most the game is finished, but grid generation is missing, and i want to know how does binary sudoku grid generation works
I tried ...
0
votes
1
answer
44
views
Python problem with checking and filling 2D-list in a loop with True and False
so I have a function generateSudoku() which should check my 2 Dimensional List which goes from [0][0] to [8][8] (81 fields), and fill in the fields with random numbers by following the rules of a ...
0
votes
0
answers
19
views
Sudoku check subboxes for duplicates
i have to check the validity of a sudoku as a homework. the rows and cols were no big deal, but i'm stuck at checking the boxes.
i want to loop through the 3x3 sub-boxes and check them for duplicates, ...
0
votes
2
answers
28
views
Java: Sudoku Array not Filling
I've been trying to build a sudoku, starting with a 9x9 array that ensures no numbers in a given column nor row are the same (ie sudoku without the 3x3 boxes). I've set my code as seen below, but I ...
1
vote
0
answers
43
views
Is there an algorithm by which you can remove cells in Sudoku?
I'm trying to make a sudoku generator. I have to remove some cells from sudoku field, but I can't remove more than 30 cells. I wrote an algorithm that removes random cell (if without this cell sudoku ...
-1
votes
1
answer
52
views
Setting up puzzles for a parallel sudoku solver [closed]
I am trying to implement a parallel sudoku solver by apportioning the problems between cores where a simple backtracking algorithm is employed. I want the jobs to be distributed such that given a ...
1
vote
1
answer
67
views
C# recursive programming: jump onto previous step in code
I have been given the task to write a sudoku program, which solves the sudoku wikipedia example.
The method which solves the sudoku puzzle has to be a recursive method.
It first checks if the sudoku ...
1
vote
3
answers
51
views
How to print Sudoku board using Python class?
Exactly as my post title says, I'm trying to create a class to solve Sudoku game and I wanted to print a board using OOP style and if name == "main":
My output suppose to look like this:
...
-1
votes
0
answers
65
views
How to color this graph using the minimum number of different colors?
void Sudoku::coloreGrafo(int currNodeId){
for(Node n : grafo.getNodes()){ // Loop through the entire graph.
if(n.getId() == currNodeId){ // Find the node ID in the graph.
for(...
1
vote
2
answers
59
views
Getting a list of 3 by 3 boxes in a Sudoku puzzle
Assuming the sudoku puzzle is a 9 by 9 and is filled with 0-9. I want is 9 lists, with each list containing a 3 by 3 Sudoku box.
This is what I have:
grid = [[5, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 1, 0,...
0
votes
2
answers
38
views
want to use getRow inside allRowsValid for sudoku solver how can i solve it?
So i have been trying to write a sudoku solver and i had to complet methods inside an extend class here's the head of the code:
class Board extends EventEmitter {
constructor(board) {
super();
...
0
votes
0
answers
24
views
Simple checking sudoku is vaild in java [duplicate]
Please, I do need some help.
I need help with my checking sudoku valid codes.
And here's my code:
package Array.MultiDemensionArray;
import java.util.*;
public class CheckSudoku {
public static ...
1
vote
1
answer
57
views
Sudoku Recursive Backtrack Aid in C
I am relatively new to coding and recursion has been a thorn in my side. I need help with implementing backtrack recursion.
Here is my sample code (Assume all helper functions work correctly [and they ...
1
vote
1
answer
67
views
Why doesn't this generate sudoku puzzles with unique solutions?
I built a program that creates sudoku puzzles, but found that the solutions weren't always unique, so I implemented a solver to try and check that.
My unique() function returns that the puzzles I ...
0
votes
1
answer
52
views
How to go through each sub-grid 3x3 using for loop?
I have been working on sudoku. The size of the original grid is 9x9 (a list containing 9 lists, each of which is a row). I need to check whether the digits only occur once per 3x3 sub-grid. In order ...
0
votes
0
answers
36
views
My sudoku solving program always returning unsolved grid
My program uses backtracking for solving sudoku puzzles. Below is my full code of the class. In this puzzle I am expecting two results. In the solve() function there I print the grid just to verify it ...
0
votes
2
answers
44
views
How can I store the occurences of a number in a sudoku subgrid (3x3)?
So I've been trying to store all the occurences of numbers from 1 to 9 in an array. I've succeeded for rows and columns and tried to apply the same logic for subgrids of 3x3 but to no avail.
My sudoku ...
0
votes
1
answer
43
views
Is there a way to make a "clickable" button, that is actually a text field?
I am making a Sudoku App using Java & Swing, and I was wondering if there was a way to edit one "box" in the 2d array using a MouseEvent and getX(), getY(). So for example, if the board ...
0
votes
1
answer
52
views
How to reset randomness in a function in a sudoku generator in javascript
I am building a sudoku generator which has randomness in it. In my code, there is a function that generates that sudoku. The problem is that I can't get the two sudoku's to be different
I tried ...
1
vote
0
answers
63
views
Get all the subgrids from a Sudoku board using only NumPy methods
I have to write a SudokuBoard class using only NumPy. As part of this class I want to define the get_block_idx_with_highest_sum() function which will return the index of the subgrid (3x3) which has ...
0
votes
1
answer
138
views
Solve Sudoku using iterative Breadth First Search
I have a task to solve sudoku using iterative Breadth first Search algorithm but I'm struggling with applying this algorithm exactly to this problem.
I figured out that I need a queue and I have to ...
1
vote
3
answers
124
views
Why is my Sudoku Solving Python code running so slow using the same logic as a faster code?
I made a sudoku solving code in python, closely following the solution given on GeeksForGeeks, but my code runs really slowly, albeit producing correct results.
It took over 2 minutes to run, whereas ...
1
vote
1
answer
78
views
recursive backtracking algorithm that counts all solutions
I'm building a sudoku generator-solver app and currently finishing the hiding algorithm for useless cells.
I have a working backtracking algorithm that returns true when the solution is found, but I ...
0
votes
0
answers
59
views
How to enter Sudoku game notes in a 9x9 cell - Android studio
I'm newbie to java and Android studio.
After many troubles and experience from a lots of mistakes, I have created sudoku game and it is almost finished but I have stuck at notes as shown in image (red ...
1
vote
1
answer
57
views
I can not understand why Sudoku does not fill
Create a program that resolves a sudoku.
A valid sudoku has only one possible solution.
I can not understand why Sudoku does not fill
The code must be filled in via ASCII
Parameters are taken via go ...
0
votes
1
answer
71
views
Sudoku Validator is not returning correct boolean
I'm writing a sudoku validator and I've run into a problem at the very end of it. I'm very new to coding, so please be patient with me. The function sudokuIsValid is supposed to take a puzzle (an ...
0
votes
0
answers
18
views
malloc Segmentation Fault in Loop
I'm trying to validate a sudoku puzzle using 11 threads, 1 to check all the 3x3s and then 1 to check all rows and 1 to check all columns. The code works as it runs perfectly on my Mac but on my ...
0
votes
1
answer
62
views
How do I get pyTesseract to only get numbers from an image
I've been trying to make a sudoku solver taking an input of sudoku game in png form.
I've tried to turn the digits in image into numbers so that I can put them on a list and implement an algorithm ...
0
votes
1
answer
209
views
4x4 Sudoku Solver in C code doesnt produce any output
I am trying my hands at making a 4x4 Sudoku solver but I do not understand why the code produce any output. Is the loop running for too long or have I done a stupid yet fatal mistake in the do while ...
0
votes
1
answer
115
views
Sudoku solver using recursion and backtracking
I am trying to implement a Sudoku solver using Java. This is the code I've written as of now. If I try to run it, it goes on to an endless loop that keeps on printing the first row of the Sudoku board,...
0
votes
0
answers
32
views
input limited inteager numbers in 9 digits
out = [[]]
for a in range(9):
for i in range(1):
while True:
grid = input("input: ")
if grid.isnumeric() and int(grid) >=0 and int(grid) <10:
...
0
votes
1
answer
26
views
modifiedSentence = a solved sudoku well it will print it close to each other i want it to be every 3 on col or row make a advanced space it means boxs
for i in range(9):
for j in range(9):
print(modifiedSentence[i][j], end=" ")
print()
modifiedSentence =
7 8 1 2 6 9 3 4 5
3 2 4 7 1 5 6 9 8
5 6 9 4 3 8 1 2 7
...
1
vote
1
answer
48
views
How to print "-1" if sudoku has no solution?
I have solved the sudoku using JavaScript but I want to print -1 if the given sudoku has no solution. I have done it using recursion and have exhausted all the ways that I could think of. Please help ...
0
votes
0
answers
30
views
Created a sudoku on pygame, stuck with creating a function that allows player to insert value into selected grid
Sudoku code
Created a sudoku board and uses a sudoku API to generate the skeleton numbers but having trouble selecting position on win to blit in value. Nothing is appearing on the win after entering ...
0
votes
1
answer
42
views
List is resetting after every update Python, any way to make not reset and still update
I'm trying to make a Sudoku solver that takes a picture of a board in a Sudoku app and then solves it. I've made the actual program that solves it and it works. I'm just trying to get the board from ...
0
votes
1
answer
159
views
16x16 sudoku solver using hex characters
#include <iostream>
#include <fstream>
#define N 16
using namespace std;
string grid[N][N];
string allowed[16]= {"0","1","2","3","4",&...
1
vote
0
answers
60
views
Is there a way to get a random solution from pycosat every time I run it?
I am given a completely blank sudoku and I want that it should produce fairly different answers when executed.
Currently I am choosing a random integer say( x ) and iterate over solutions till I reach ...
0
votes
2
answers
64
views
What is N-2 doing in the Sudoku for loop to validate the block JavaScript
I was researching solution to the Sudoku Solution Validator algorithm and came across this example. The code works and validates but what I do not understand is why in the for loops to get to validate ...
1
vote
0
answers
151
views
Python Sudoku Solver with multiple solutions
i am new to programing an trying to learn it. As I am always looking for new intressting python tutorials i have come accross an tutorial for a sudoku solver using backtracking technique.
https://www....
0
votes
3
answers
104
views
Optimized coordinates selection in 2D numpy array
I have a numpy array of coordinates. I want to select those between Xmin and Xmax and between Ymin and Ymax.
Here is my code :
grid = np.random.randint(2, size=81).reshape(9,9)
List_of_coordinates = ...
1
vote
1
answer
267
views
How to solve Sudoku with Python?
I was wondering how to solve this Sudoku board in Python using Human input and Computer solving.
I have a Human and Computer solve def. I tried using rows and columns to solve and it just wouldn't ...
0
votes
2
answers
103
views
How to index a 3x3 subblock of a 9x9 Sudoku board
I'm working on a Sudoku solver (for a Leet problem) and I'm able to manipulate the 9 x 9 array of numbers in terms of rows and columns pretty easily using basic indexing, e.g.,
board[row,:] or board[:,...
1
vote
2
answers
67
views
Python: why does this variable value change?
I am learning recursion and came through this code (not mine: https://github.com/kying18/sudoku) and cannot figure out why the variable example_board changes value. It is never addressed again and no ...
0
votes
0
answers
39
views
What is the O(n) of this leetcode solution?
I was wondering what the O(n) for this leetcode solution would be. To clarify, this code is supposed to validate a sudoku puzzle. The portion of my code that would run the longest would be the last ...
1
vote
0
answers
40
views
Using py-sudoku library, how can i add the numbers in the board to the loop of entry boxes i created inside a frame with tkinter?
I am creating a sudoku GUI and i dont know how to insert numbers from the given board (with empty spaces based on the difficulty level of the puzzle) and put them into the 9x9 table of entry boxes i ...
1
vote
1
answer
25
views
How do I make an error message print to a file?
I am creating a Sudoku solver that sends the solved puzzles to a file, but one of our tasks is for the solver to tell you if a puzzle is unsolvable. I can get the error message to print in python or I ...
-1
votes
1
answer
72
views
How to solve multiple sudokus in one file with python?
I am making a sudoku solver for school and one part of it, is that it needs to be able to solve multiple sudokus in a file. Currently it can solve one at a time, but how would I code it to solve ...