Is there any math way to solve a Sudoku

  • Context: High School 
  • Thread starter Thread starter eljose
  • Start date Start date
  • Tags Tags
    Sudoku
Click For Summary

Discussion Overview

The discussion revolves around the mathematical methods for solving Sudoku puzzles, exploring whether there are exact algorithms or formulas that can be applied manually, as well as the computational aspects of solving them. Participants touch on the historical context of Sudoku, its complexity classification, and various solving techniques.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants inquire about the existence of a mathematical algorithm to solve Sudoku puzzles manually, expressing a preference for non-computerized methods.
  • It is noted that Sudoku puzzles are NP-complete, indicating that no known easy methods exist for solving them.
  • One participant suggests modeling Sudoku as a linear programming problem or a system of algebraic equations, though they acknowledge that these methods may not be efficient.
  • Another participant mentions that brute force methods are commonly used in computer programs to solve Sudoku, but questions the enjoyment of such an approach.
  • There is discussion about the average time it takes to solve Sudoku puzzles, with varying claims about the speed of different solvers.
  • Some participants argue that there are algorithmic methods to solve Sudoku, while others suggest that the difficulty of a puzzle is subjective and depends on the techniques required to solve it.
  • Participants discuss the relationship between the number of given entries in a Sudoku puzzle and its difficulty, with some suggesting that fewer entries do not necessarily correlate with increased difficulty.
  • There is mention of specific techniques, such as the "pigeonhole" principle, that may be used in solving tougher Sudoku puzzles.

Areas of Agreement / Disagreement

Participants express differing views on the existence and nature of mathematical methods for solving Sudoku, with some asserting that algorithmic solutions exist while others emphasize the subjective nature of puzzle difficulty. The discussion remains unresolved regarding the effectiveness and efficiency of various proposed methods.

Contextual Notes

Participants note that the classification of Sudoku as NP-complete suggests inherent complexity, and there are references to the potential inefficiency of certain mathematical approaches. The discussion also highlights the subjective nature of puzzle difficulty and the variability in solving times among individuals.

eljose
Messages
484
Reaction score
0
Is there any math way to solve a "Sudoku"

I didn,t know where to put this question...my doubt is if there is an exact math way to solve a "Sudoku"...:rolleyes: :rolleyes: ( i don,t think is necessary to explain the game isn,t it?) as far as i know Euler himself "invented" the game about 300 years ago..my question is if he did know any formula to solve any "Sudoku" or if there is a math algorithm formula or something to solve the "Sudoku" whatever is it...i am not interested in computer program to solve sudoku but a manual algorithm for their solution... thanks in advance.
 
Last edited:
Mathematics news on Phys.org
eljose said:
I didn,t know where to put this question...my doubt is if there is an exact math way to solve a "Sudoku"...:rolleyes: :rolleyes: ( i don,t think is necessary to explain the game doesn,t it?) as far as i know Euler himself "invented" the game about 300 years ago..my question is if he did know any formula to solve any "Sudoku" or if there is a math algorithm formula or something to solve the "Sudoku" whatever is it...i am not interested in computer program to solve sudoku but a manual algorithm for their solution... thanks in advance.

Sudoku's are NP-Complete. That means that there are no known easy ways to do them.
 
[Sudoku] was designed anonymously by Howard Garns...

(snip)

...likely inspired by the Latin square invention of Leonhard Euler...
Source: http://en.wikipedia.org/wiki/Sudoku

Not a mathematical way, but computer programs are used to find solutions using a brute force method. But what fun is that?

On another note, what does "designed anonymously by [name]" mean?
 
How long does it take to brute-force a Sudoku puzzle on average?
 
I'm not sure, but like all brute forcing programs, the time depends on the speed of the processor. That Wiki article says a well-written program could be so efficient as to eliminate combinations until there's one left for each cell and then use the previous information for more eliminations. I wonder how long it'd take to solve a whole book of puzzles using the newest Intel Xeon processors...
 
z-component said:
I wonder how long it'd take to solve a whole book of puzzles using the newest Intel Xeon processors...

I'm not sure about the Xeon, but at 3 GHz a Pentium 4 can do about 600 million additions per second!
 
Well, solving it "mathematically" is a rather vague term.

Certainly you could model the problem in a mathematical fashion. You could set it up as a linear programming problem, or a system of algebraic equations. Neither approach is likely to be efficient.

I would (essentially) set it up as a collection of boolean formulas, and run the program I've written written for the purpose of solving puzzles of this genre when (essentially) modeled as a collection of boolean formulas. :smile: Of course, most people would call it clever brute force, so *shrug*.

(And I've never tried it on sudoku, but I would expect it most to be solved rather instantly)


And a technical note: the general Sudoku problem is NP-complete. (or at least I'd believe so) The 9x9 Sudoku problem is O(1). :smile:
 
Hurkyl said:
And a technical note: the general Sudoku problem is NP-complete. (or at least I'd believe so) The 9x9 Sudoku problem is O(1). :smile:

It's very easy to show that it's closely related to latin square/quasigroup completion. I haven't actually seen any proof that the 'single solution only' subset is NP-complete though.

Of course the 9x9 sudoku is constant order, it's just a good sized constant.

I've seen it suggested that 9x9 sudokus will usually have a 2-field back door. So, brute force type tactics are going to be pretty effective for those.
 
takes 5-20 minutes to solve the advance 9x9 sudokus. There is an algorithmic method to solving it, and i consider algorithms to be mathematical
Is the brute force method people are mentioning just trying every combination?
 
  • #10
5-20 minutes?

I know people who can do it in 3
 
  • #11
Pengwuino said:
5-20 minutes?

I know people who can do it in 3
People who can solve an advanced sudoku in 3 minutes? Go to www.websudoku.com and check out an "evil" puzzle. I would certainly like to see someone solve one of those in 3 minutes.
 
  • #12
Of course there is an algorithmic (mathematical) way of solving them, eljose, otherwsie they wouldn't be solvable at all. You can program it relatively easily, I'm led to believe. An interesting question is then to decide how hard a sudoku can be (minimal number of specified entries), I think 17 is the lowest bound from memory.
 
  • #13
matt grime said:
Of course there is an algorithmic (mathematical) way of solving them, eljose, otherwsie they wouldn't be solvable at all. You can program it relatively easily, I'm led to believe. An interesting question is then to decide how hard a sudoku can be (minimal number of specified entries), I think 17 is the lowest bound from memory.

The number of entries is not strongly related to how difficult a sudoku is to solve. Supposedly many of the 17 entry sudokus are fairily easy to solve.
 
  • #14
'hard' or otherwise is a purely subjective opinion. Every sudoku is exactly as hard as anyother in some sense; some are just quicker to solve than others. I was purely using 'hard' to refer to the number of starting entries.
 
  • #15
matt grime said:
'hard' or otherwise is a purely subjective opinion. Every sudoku is exactly as hard as anyother in some sense; some are just quicker to solve than others. I was purely using 'hard' to refer to the number of starting entries.

Well, there are, of course, unsolvable sudoku which are clearly harder to complete than solvable ones.

Generally, 'harder' refers to the techniques that would be communly used to solve the sudoku, rather than the number of starting cells.
 
  • #16
I've actually written a computer program for solving sudokus. All it does is keep track of all the possible numbers that could be in a space, and eliminate them one by one until only one is left. It runs almost instantaneously, and as far as I can tell it solves all but the very toughest sudokus, which I think will require a guess at some point.
 
  • #17
pengiwuino...3 mins to solve an evil sudoku( from websudoku.com)? that's nuts...i gues they ain't watching tv while doing it.

Pi-r8...none of the tougher sudoku's require a guess.Sometimes you must apply a "pigeonhole"(or rather n in n boxes technique)...which might be tough to code...my best guess would be to code for a bipartition.
Another technique is to simulate chess like strats for each # separately.

what does 17 entries mean? on a 9x9?
 
  • #18
No it's not "evil sudoku", its just the ones they print in our universities newspapre and its only the MW ones that aren't that hard.
 
  • #19
ah ... print some "evil sudokus" from websudoku.com and give them to your friends...See if they can finish those in 3minutes.
 
  • #20
Yeah, anyone can solve the easy puzzles in a few minutes.

And neurocomp, I think the 17 is referring to the number of entries given at the start of a puzzle.
 
  • #21
mattmns said:
People who can solve an advanced sudoku in 3 minutes? Go to www.websudoku.com and check out an "evil" puzzle. I would certainly like to see someone solve one of those in 3 minutes.

No that hard at all :approve:
 

Attachments

  • SUDOKU.PNG
    SUDOKU.PNG
    6 KB · Views: 669
  • #22
As for sudoku "hardness", my subjective opinion is the following:
The longer the chain of reasoning must be in order to eliminate a particular choice, the "harder" is the sudoku. (and also, the number of possible branches you need to consider)

Of course, one might say that sudokus aren't hard at all, they merely require patience of you.
 
  • #23
neurocomp2003 said:
Pi-r8...none of the tougher sudoku's require a guess.Sometimes you must apply a "pigeonhole"(or rather n in n boxes technique)...which might be tough to code...my best guess would be to code for a bipartition.
Another technique is to simulate chess like strats for each # separately.

I'm not sure what you mean by pigeonhole, or n in n boxes. Is it something like noticing that there's only two places a number can go, so you try one and see if it leads to a contradiction? Because that's what I mean by guessing. I'm sure I could code that with a selfreferencing function, but it's been a while since I've used one of those so I've kind of forgotten how.
 
  • #24
no... if you have 157*15*17*147*489...in a row/column/3x3 box...
then you know that the 4 goes in the box with 147...because
of the n in n boxes(n=3 in this case) 157*15*17...
this would be harder to code for but if you keep track of what goes in a row and column then you can.
 
  • #25
Popey said:
No that hard at all :approve:

Actually, this was a cheat
:biggrin:
 
Last edited:
  • #26
http://www.javaonthebrain.com/java/sudokuspoiler/ has a program in java that solves sudokus very quickly. I placed the numbers from one of those evil puzzles into the spoiler, and it reported that it took 15 milliseconds to solve.

The spoiler on that website only tells you one possible solution, though. If there are multiple solutions, it apparently takes the first one it finds. Although it doesn't mention that there may be multiple solutions, it will state when there is no solution.
 
  • #27
I thought each Sudoku, by definition, has a unique solution?
 
  • #28
A unique solution is usually one of the conditions for it to be a sudoku. However, if you were to write a program that's trying to solve one inputed by a user you don't begin with a guarantee that this is the case. Rather than try to list them all if the input allows multiple solutions, it would be simpler to put out the first solution found (listing them all would be impossible in some cases, it will actually take an empty board as input)..
 
  • #29
Sudoku

The better algorithms for solving sudoku on computers use
a combination of logic together with brute force, when the logic
can no longer get any further.
I use that technique in mine, so that I can provide a single step
help function that follows normal reasoning at least for all the easier
puzzles, that can be solved by straight logic.

Dave
http://www.sudokuoftheday.co.uk
 
  • #30
I thought each Sudoku, by definition, has a unique solution?

Try the soduko I posted previously in this thread. It has three solutions.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 26 ·
Replies
26
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
5
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K