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.

Completed puzzles are always a type of Latin square with an additional constraint on the contents of individual regions. For example, the same integer may not appear twice in a given row, column, or any of the nine 3×3 sub-regions of the 9×9 playing board. In each puzzle the player must build a solution around a subset of pre-filled digits.

The puzzle was popularized in 1986 by the Japanese puzzle company Nikoli under the name Sudoku, meaning single number. It became an international hit in 2005.

A great deal of literature has been written about solving Sudoku puzzles and they present a very interesting and common subject for mathematicians and programmers. Solving complex Sudoku puzzles may involve combinatorics, group theory, computational complexity, guessing and backtracking. The total number of distinct grids has been calculated as approximately 6.671×1021, so brute-forcing complex puzzles may not always be successful in a desirable timeframe.

The following resources explore the logic and mathematics behind Sudoku puzzles in greater detail:

History:

Number puzzles appeared in newspapers in the late 19th century, when French puzzle setters began experimenting with removing numbers from magic squares. Le Siècle, a Paris-based daily, published a partially completed 9×9 magic square with 3×3 sub-squares on November 19, 1892. It was not a Sudoku because it contained double-digit numbers and required arithmetic rather than logic to solve, but it shared key characteristics: each row, column and sub-square added up to the same number.

On July 6, 1895, Le Siècle's rival, La France, refined the puzzle so that it was almost a modern Sudoku. It simplified the 9×9 magic square puzzle so that each row, column and broken diagonals contained only the numbers 1–9, but did not mark the sub-squares. Although they are unmarked, each 3×3 sub-square does indeed comprise the numbers 1–9 and the additional constraint on the broken diagonals leads to only one solution.

These weekly puzzles were a feature of French newspapers such as L'Echo de Paris for about a decade but disappeared about the time of World War I.

According to Will Shortz, the modern Sudoku was most likely designed anonymously by Howard Garns, a 74-year-old retired architect and freelance puzzle constructor from Indiana, and first published in 1979 by Dell Magazines as Number Place (the earliest known examples of modern Sudoku). Garns's name was always present on the list of contributors in issues of Dell Pencil Puzzles and Word Games that included Number Place, and was always absent from issues that did not. He died in 1989 before getting a chance to see his creation as a worldwide phenomenon. It is unclear if Garns was familiar with any of the French newspapers listed above.

The puzzle was introduced in Japan by Nikoli in the paper Monthly Nikolist in April 1984 as Sūji wa dokushin ni kagiru (数字は独身に限る?), which can be translated as "the digits must be single" or "the digits are limited to one occurrence." (In Japanese,"dokushin" means an "unmarried person".) At a later date, the name was abbreviated to Sudoku(數獨) by Maki Kaji (鍜治 真起 Kaji Maki?), taking only the first kanji of compound words to form a shorter version. In 1986, Nikoli introduced two innovations: the number of givens was restricted to no more than 32, and puzzles became "symmetrical" (meaning the givens were distributed in rotationally symmetric cells). It is now published in mainstream Japanese periodicals, such as the Asahi Shimbun.

Wikipedia Article: http://en.wikipedia.org/wiki/Sudoku

1192 questions
2
votes
1 answer

Recursive Sudoku Solver doesn't work in Java

I had written a Sudoku game including a solver in C, and wanted to try it out in Java so people could use it a little easier (portability). I figured the port would be fairly simple because of the vast similarities between the languages, but it…
Caleb Stewart
  • 643
  • 6
  • 21
2
votes
2 answers

Sudoku Backtracking Python to find Multiple Solutions

I have a code to solve a Sudoku recursively and print out the one solution it founds. But i would like to find the number of multiple solutions. How would you modify the code that it finds all possible solutions and gives out the number of…
hobbes18
  • 23
  • 3
2
votes
2 answers

How to get my sudoku solver to read from text file in python?

I am having trouble figuring out how to read from a text file for my Sudoku solver. So I can get it to read the board from a text file, and I can get my code to solve the board when it's in the code, but I can't bet them to read and solve together.…
user17630930
2
votes
1 answer

Overlapping Frames with PySimpleGUI

I want to create a GUI using pySimpleGUI that resembles the Killer Sudoku game. For those unfamiliar with Killer Sudoku, it is similar to regular sudoku however there is an extra level of complexity where not only do you have the 9 3x3 boxes where…
2
votes
1 answer

Can't get backtrack to work on recursive javascript sudoku sovler

I'm racking my brain but I can't see where I've gone wrong, from the console log it appears it's an issue when it comes to backtracking not working correctly, I think it has something to do with how I'm working with position object, any help would…
2
votes
2 answers

Sudoku solver multiple solutions

all below I have an outline for a 9x9 Sudoku Solver, but I'm not sure how to incorporate multiple solutions to a certain Sudoku with partial entries, if it hasn't been already. Can someone run me through this? This algorithm uses backtracking…
Tom
  • 59
  • 2
  • 6
2
votes
0 answers

implementing sudoku XV board

I have found out the solution for standard sudoku however I do not know what to do with sudoku xv. A Sudoku XV puzzle consists of a standard Sudoku grid with the addition of X and V markers between neighbouring pairs of squares. X markers show all…
hash
  • 21
  • 1
2
votes
2 answers

Writing a number/text in a Pygame Rect

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 =…
2
votes
1 answer

Python Valid Sudoku Board Checker 9x9 validate squares but not showing output results

I have been working on a task where I validate a already completed Sudoku puzzle and see if it has been done properly. I have been able to define the functions and able to section the code to different segments to allow the code to flow properly. I…
jdark99
  • 23
  • 3
2
votes
1 answer

Generating sudoku puzzle in matrix than drawing GUI

The concept of the program is to create a sudoku puzzle that can then be solved via pygame. Where I got stuck is this error: Traceback (most recent call last): File "C:\Users\Lenovo\Desktop\Sudoku Solver\GUI.py", line 307, in main() …
Alex Mihoc
  • 80
  • 1
  • 7
2
votes
2 answers

Python Sudoku Backtracking Solved! But Not Returning Answer

I have correctly made a sudoku backtracking solver. But now I need to get the solution, but for some reason I keep getting the original sudoku grid. The sudoku problem has a unique solution. answer = [] count = 0 def solution(sudoku): global…
2
votes
1 answer

Sudoku solver with Javascript

I tried t build a Sudoku Solver with Javascript. The code solves it indeed but stil there are some blank spots left. I use Javascript, backtracking and recursion. In the first function i check i a number on a blank spot (0) is possible and in the…
2
votes
0 answers

Need help on the Optaplanner, Quarkus with sudoku

Did anyone used latest Optaplanner (using Quarkus + Optaplanner) to solve a Sudoku problem ? Currently I am working on a constraing programming to solve the Sudoku problem. I have followed the recent video uploaded by Geoffrey…
Utpal
  • 21
  • 1
2
votes
1 answer

sudoku game constructor

I am having trouble initializing a parameterless constructor with a defined game. Somehow it keeps on returning null if I use a getter method to return the game. Can anyone tell me what would be the best method to initialize the game? Currently I'm…
clfc
  • 23
  • 5
2
votes
0 answers

Opencv can't find the contours of an aluminium plate

I'm trying to extract this mold from this picture. I've got some code to extract it, the only thing I need are the four corners. def detect_object(image): orig = image.copy() image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) blurry =…