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

Sudoku C recursive function not working properly

I made a sudoku solver in c, and my recursive function only works for the first row than stops. It looks for the first element with the value of zero and fills it up then looks for the next value, and fills it with another solution. After it solves…
-2
votes
1 answer

c++ sudoku checker row, column, sub square

#include #include #include #include using namespace std; const int MAX = 9; typedef char BOARD[MAX][MAX]; void dis_board(BOARD); void new_board(BOARD,…
j_777
  • 1
  • 1
-2
votes
2 answers

Generate the Sukodu Random Number

Currently I am developing the Sudoku application. I need to generate a random number with given length. I know I could loop that times. but how to implement in android. I directly included the sudoku string as Public static final String …
Pixel Aswin
  • 27
  • 1
  • 7
-2
votes
1 answer

Segmenation Fault with Sudoku Implementation in C++

I have to make an n x n sudoku solver. The user inputs the n, and then the output is a solved sudoku puzzle. I did the majority of it, but I keep getting a segmentation fault. Any help would be greatly appreciated. I think it has to do with my…
-2
votes
2 answers

Sudoku backtracking using c#

I am doing a project in my programming class and I chose to do a sudoku solver. However I haven't done any algorithms before and found this quite a challenge. I have read some articles about solving sudoku, but I am struggling with the actual…
-2
votes
1 answer

Sudoku multiple solutions C

Here is my C sudoku solver using recursive backtracing, with help code from online. The program is small, and branches of the puzzle are stored on the stack and it moves forward adding new puzzle's, and if it fails to find a solution for a position…
Astralux
  • 51
  • 4
-2
votes
1 answer

How to implement this Depth-First-Search in a Sudoku Solver

Some backstory I made a Sudoku solver which works if any given cell has only 1 option to fill in it's given row/column/group. But this solver doesn't work if the options are above 1, so I tried to make a recursive solver which takes turn for every…
f.rodrigues
  • 3,499
  • 6
  • 26
  • 62
-2
votes
1 answer

Segfault in sudoku solver

I am writing a Sudoku solver to practice my skills for next semester. When I try to run it I get a segmentation fault. Using gdb, I track it to this code function: vector sudoku::valid_set(int row, int col) { vector valids; …
gsoble
  • 31
  • 1
  • 2
  • 9
-2
votes
1 answer

C++ sudoku (beginning coder)

I want to prompt the user for 9 integers between 1 and 9, and I want to output whether the integers are valid or invalid, depending on whether there is one of each number or not. Here is my code now: #include #include "conio.h" using…
Stephanie Fu
  • 79
  • 1
  • 9
-2
votes
1 answer

sudoku backtracking algorithm in Scheme

I have a problem with my sudoku-solver function, it's not doing the backtracking process and i can't see why, just when the backtracking comes, the function stops, here is the code: (define (solve-sudoku grid) (define blank-space…
ronsuez
  • 1
  • 1
  • 6
-2
votes
1 answer

Turning some of the JTextBox to be JLabels in a Sudoku Game

So here is what i have so far for my sudoku game. Now my grid only displays textboxes where a user can input numbers but nothing will happen yet. I want to know how to make it so that the user can only input one character and only numbers. i would…
user3512387
  • 69
  • 1
  • 1
  • 6
-2
votes
1 answer

Backtracking in C

I've heard about backtracking and I've searched a little bit .I thought I got the idea and wrote this piece of code to solve sudoku , but it seems to give wrong solutions (for example repeated numbers in a row) , what exactly i am doing wrong here…
-2
votes
2 answers

How do I read in a .txt file and store the data in a 9x9 array? c++

I'm new to c++ and i'm trying to read in a file and store it in a 9x9 array, can anyone explain how i can do this whilst keeping it as simple as possible? The aim is too make a Sudoku solver. File looks like; 0 3 0 0 0 1 0 7 0 6 0 0 8 0 0 0 0 2 0 0…
-2
votes
1 answer

Sudoku Checker Java

I have a question about a problem I'm having with a code i am writing. I need to create a Sudoku board checker. The goal is to extend the Sudoku class (to make the CheckableSudoku class) by using the the 5 specific methods I have to use…
Alex
  • 31
  • 5
-2
votes
1 answer

Can't make/configure the difficult function

While solving sudoku I can remove possibility digits (1) and (2) from the cells D[1,2] and D[2,2]. Because (8) and (9) are possible only in those cells, so those cells are either (8 and 9) or (9 and 8). This means that digits (1) and (2) are at the…
Hasan A.
  • 23
  • 4