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 algorithm, brute force

Iam trying to solve a sudoku board with a brute force algorithm, I cant really get this algorithm work correctly. There is created a object for each row, column and box that contains all squares(cells) that belongs to the actually column, square and…
user265767
  • 559
  • 3
  • 12
  • 27
-3
votes
1 answer

sudoku validator in Ruby

I tried converting python file to ruby for sudoku validator. can someone help me to complete? class Sudoku def isinRange(board) @N = 9 for i in (0..@N) for j in (0..@N) if ((board[i][j] <= 0) or (board[i][j] > 9)) …
-3
votes
1 answer

I am beginner (day 3 of learning python). I want to know what is wrong with my sudoku solver. why is it not showing result?

grid = [[0, 4, 8, 2, 0, 0 ,0, 0, 1], [1, 0, 0, 3, 8, 4, 7, 2, 6], [3, 0, 0, 7, 0, 1, 9, 4, 8], [0, 7, 2, 6, 4, 5, 1, 8, 0], [8, 0, 0, 0, 0, 2, 4, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 7], [0, 8, 4, 0, 0, 0,…
-3
votes
1 answer

What is the problem with my sudoku finder?

For Code Signal I have submitted a solution to the sudoku2 problem. However, this works for all test cases except one where a number repeats in a 3 by 3 block in the middle of the puzzle and the function returns true instead of false. The program…
J. Smith
  • 1
  • 1
-3
votes
1 answer

Why doesn't my Sudoku program return an output?

So I have tried to implement a Sudoku via backtracking algorithm. I don't see why my code is not giving an expected output. What I did was, I created a loop in which it checks for an empty cell (represented with 0) in the sudoku. As it finds it,…
-3
votes
1 answer

Sudoku Gui Issues

I am required to create a Suduku Game Board that looks like this: Here are the requirements I need for this assignment, but am having some issues. Use two for loops to draw the text fields instead of brute-force of listing 81 text fields. You…
-3
votes
1 answer

Php - string to array 3 dimensions

I come to you to find a solution to my problem: I have a flat string like this: $chaine = "519637824467582931832419576721894365346125789985376412698243157273951648154768293"; I want to convert this dimensional array chain, this format here: $tab =…
-3
votes
1 answer

Solve Sudoku using Back tracking Algorithm in C

I had a feel to solve sudoku using C programming in early October, and soon I came to know its no easy task. Currently, I did write a code to do all the functioning but there seems to be an error somewhere which is preventing the desired result to…
axelonet
  • 113
  • 5
-3
votes
1 answer

Sudoku Solver in C, runs perfectly, but ends with a segmentation error. Can't find the source

I have written a program in C that solved Sudoku puzzles. It works perfectly, and prints out the correct solved puzzle, however, just before the program should end, I get a segmentation fault and the program crashes. I am struggling to find where…
Vorkos
  • 212
  • 1
  • 11
-3
votes
1 answer

Segmentation fault: 11 (Sudoku Board)

When I try to display my sudoku board in my program, Terminal says: Segmentation fault: 11 Here is a copy of my code: #include using namespace std; const int DIMEN = 9; void generate_valid(int [][DIMEN]); // generate a valid sudoku…
Josh Simani
  • 107
  • 10
-3
votes
1 answer

Sudoku method and solver

I am trying to write a Sudoku solver using back tracking ad recursive, when I finished every thing, my output is just " [] " with nothing in the bracket. and my expected output should the 3 solution in my tester. package sudoku; import…
孔伟杰
  • 1
  • 3
-3
votes
2 answers

Making my own sudoku puzzle

I’m trying to write a basic sudoku solver from scratch with a my own made algorithm where my program solves some of the empty elements but not all of them. Whatever elements it solves, I just copy that sudoku board replace the old board and run my…
dabrams493
  • 61
  • 6
-3
votes
3 answers

Sudoku Checker Program C

I'm trying to complete a sudoku solution checker program in c. I'm still trying to understand the steps in building this program before I start coding it. I found this example online…
tonomon
  • 1
  • 4
-3
votes
1 answer

Sudoku Solving algorithm in C++

I have learnt C++ of late and I'm trying to contrive a Sudoku - Solving algorithm. I developed this algorithm but when I run the program, the computer takes input values from me but then doesn't give any output. Any help would be appreciated. Kindly…
Siddharth Joshi
  • 157
  • 1
  • 9
-3
votes
2 answers

Sudoku Checker in C Issues

I have Sudoku checker assignment for my class and my task is to be able to create a code that will ask how many puzzles the user would like to solve then they'll input all of the numbers themselves. After they input all the numbers, the output would…
Perez
  • 21
  • 1
  • 6