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

High quality test cases for Sudoku Solver

I'm making my own version of Sudoku Solver. Are there any open source test cases that I can use to test the efficiency of my algorithm (I don't just want randomized test cases. I want test cases that are marked easy, medium, hard). Thank you very…
Tran Anh Minh
  • 196
  • 2
  • 12
2
votes
1 answer

How do you create quickCheck properties with a Property output in Haskell?

How do you create a property that checks that all solutions provided are valid solutions, I need it to output as a Property, but I'm unsure how to do that, I only understand how to do Bool outputs for quickCheck properties. See below for my attempt,…
Alex
  • 394
  • 1
  • 4
  • 15
2
votes
2 answers

separating numbers with coma in python

I am building a sudoku game, I found a site that can provide me 1 million pre generated games. I downloaded the file (CSV) and want to prepare it for frontend use. Each game is 81 numbers…
Waelio
  • 59
  • 1
  • 9
2
votes
2 answers

Strategies for solving inequality sudoku?

A twist on the classic sudoku solver that I've recently run into is the (rather crazy) inequality sudoku, which is your classic sudoku puzzle with the added twist that there are inequality conditions added to each box. Now, I've managed to scratch…
Nathaniel
  • 21
  • 2
2
votes
0 answers

How to add Specific Border to Labels

I am making a Sudoku Solver in a JavaFx Application. I have got the grid ready as shown below, but I don't know how to add the center border to distinguish between the smaller boxes. Like in a normal sudoku, I want to get the border between the…
Nishant Jalan
  • 844
  • 9
  • 20
2
votes
1 answer

How to store unique copy of object in a list, in this case a semi solved jagged array of sudoku cells

How can I store data (list>) in a way that I can access a previous state? This is for a Sudoku solver written in c#. I have tried generating a "higher level" list (List>>) and storing in this, however it seems this…
2
votes
2 answers

Error by solving sudoku using backtracking

I'm trying to implement a code of (SolveSudoku) by using backtracking. But I always get an error. I looked at many solutions in the internet ,but they are different which confuses me. that's why I'm asking here. I think the mistake can be in the…
Alaa Alsayed
  • 133
  • 8
2
votes
1 answer

Sudoku solver is slow, needs considering constraints earlier

I have an NxN sudoku solver written in prolog. The code below works fine for 4*4 solving. (I have some Domain infos) But it is slow for 9x9. I've tried many way to improve the create row function, that it is already considering that every value in a…
Falcon
  • 29
  • 6
2
votes
2 answers

C++ why struct object values reset back to ZERO at end of loop

I created a simple struct object that holds 2 values - number (specific number) and count (counter for how many times number appears). typedef struct matrixMissNumber { int number; int count = 0; } Then I created a list called,…
2
votes
8 answers

Sudoku solver evaluation function

So I'm trying to write a simple genetic algorithm for solving a sudoku (not the most efficient way, I know, but it's just to practice evolutionary algorithms). I'm having some problems coming up with an efficient evaluation function to test if the…
Rich
  • 59
  • 1
  • 3
2
votes
1 answer

Recursive Backtracking for Sudoku

I'm still pretty new to coding and I am trying work on slightly harder topics such as modifying the solution for a recursive backtracking program for a sudoku. The original solution is for a sudoku of size 3x3 and I would like mine to work with a…
Z. Winters
  • 23
  • 5
2
votes
1 answer

How to solve a sudoku such that by swapping any two adjacent sub grids I still get a valid answer?

I'm given a n^2 * n^2 grid with a few numbers filled in it. I need to fill in the remaining grid using the basic sudoku rules along with one more additional condition which is to ensure that if I swap any 2 adjacent subgrids(n*n) then my overall…
Impromptu_Coder
  • 425
  • 3
  • 7
  • 27
2
votes
3 answers

JFormattedTextField is not properly cleared

I am doing this assignment, make a program that solves sudoku. I have a panel with a grid of SudokuTextBox extends JFormattedTextField. I have a MaskFormatter so that it only accepts one integer per text box. Then in my panel I have this code when a…
evading
  • 3,032
  • 6
  • 37
  • 57
2
votes
1 answer

Learning Prolog, Sudoku Solver

my problem is: While learning Prolog i wanted to make a NxN Sudoku solver. This solver will get the input like [[1,2,3,4],[3,4,1,2],[2,3,4,1],[4,1,2,3]] Where some of them might be variables. The solver has to solve that Sudoku. The problem is…
Shuumi
  • 76
  • 8
2
votes
2 answers

Parallel Sudoku Solver in Java

I have a homework that requires to implement a sequential and a parallel version of a sudoku solver in Java (using the ForkJoin Framework for the parallel one). I wrote the sequential one and it works fine. The algorithmic idea is a simple…
ssh3ll
  • 41
  • 1
  • 5