sudoku

I wanted to make a sudoku an check if it is a valid one

I wanted to make a sudoku an check if it is a valid one Question: Does any body have an idea why my valid, or doubles methods don’t want to work? First I make a new 9×9 sudoku with al positions None. afterwards with the method doubles i check whether there are any duplicates in …

Total answers: 1

Trying to Understand a python code to build up a Sudoku Solver

Trying to Understand a python code to build up a Sudoku Solver Question: def init_valid(self): # Fill out dictionary V such that V[(r,c)], where (r,c) are the coordinates of a cell, contains the set of integers that can be # written in cell (r,c) without breaking any of the rules # If a number has …

Total answers: 1

Sudoku solving taking forever to run

Sudoku solving taking forever to run Question: The example below is working however, if more zeros (empty cells) are added to the sudoku grid g, it takes longer to run, if it ever finishes. Not asking for a code review here, just I might’ve overlooked something, and I’d appreciate pointing it out. def is_solved(grid): for …

Total answers: 2

Sudoku Solver – Modify a list in-place within a recursive function

Sudoku Solver – Modify a list in-place within a recursive function Question: This is leetcode #37 (Sudoku solver). I have a question regarding modifying an input list in-place within a recursive function. The code below pretty much does the job as the print(board) does print the correct solution (I’m sure the efficiency can be improved …

Total answers: 2

How to generate all possibilities of sudoku-like grids in Python?

How to generate all possibilities of sudoku-like grids in Python? Question: I need to generate all the possibilities of sudoku-like grids/matrices. A list of 2D arrays must be returned. Note: What I am trying to generate is not really a 9×9 sudoku grid but something like the grid below, where the only condition is that …

Total answers: 3

Recursion issue in sudoku solver

Recursion issue in sudoku solver Question: I’m getting an error that I’ve exceeded the maximum number of errors in the method recuSolve. I’m using recursion to find the correct value for each sudoku box 1 by 1. ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ …

Total answers: 2

How to remove numbers in an array if it exists in another another

How to remove numbers in an array if it exists in another another Question: Here is my code so far. (Using NumPy for arrays) avail_nums = np.array([1,2,3,4,5,6,7,8,9]) # initial available numbers # print(avail_nums.shape[0]) # print(sudoku[spaces[x,1],spaces[x,2]]) # index of missing numbers in sudoku print(‘n’) # print(sudoku[spaces[x,1],:]) # rows of missing numbers for i in range(sudoku[spaces[x,1],:].shape[0]): # …

Total answers: 1

Python sudoku backtracking

Python sudoku backtracking Question: I was trying out the backtracking algorithm with an easy example (sudoku). I first tried another approach where more possibilities are canceled, but after I got the same error I switched to an easier solution. look for the first unsolved spot fill in every number between 1 and 9 and backtrack …

Total answers: 3

Writing a number/text in a Pygame Rect

Writing a number/text in a Pygame Rect Question: At the moment I create a Visualization Tool for my Sudoku solver. Now I want to display the numbers in the grid with pygame. def draw(win): global grid w = 70 x,y = 0,0 for row in grid: for col in grid: rect = pygame.Rect(x,y,w,w) pygame.draw.rect(win,BLACK,rect) rect2 …

Total answers: 2

How does the following recursive Sudoku solving function work?

How does the following recursive Sudoku solving function work? Question: I recently watched this video showing a recursive function to solve sudoku and this seems irrational, since at the end we always change the value back to zero in the end. How come the function worked in the video but doesnt work for me? Should …

Total answers: 2