Tough Sudoku solvable through Logic?

… as opposed to brute force guessing. I know computers can solve a Sudoku puzzle by simply trying all the possibilities, but obviously that isn’t as fun for humans.

I can solve easy and medium Sudoku with generalized logic rules that can be reused. But hard Sudoku sometimes devolves to a point where I have to make a wild guess that either works out or forces me to backtrack. I can still solve it using pencil, but I wanna use a pen, dammit.

When I go back to analyze those guesses, I sometimes spot a pattern that could have helped, but I rarely find an occasion to re-apply that method on new puzzles. So let’s not count techniques that involve memorization of a specific pattern that works in a small subset of cases.

Memorizing a pattern is okay if it applies to a significant fraction of puzzles. But I don’t want to memorize a gigantic look-up table of solutions to solve Sudoku puzzles in general. (Again, that’s not fun for humans)

Yes, tough sudoku puzzles can be solved purely by logic.

Most complex puzzles often require use of a strategy dubbed Y-wing. That linked site explains several other strategies.

That site is fascinating but it exposes a big problem I have with nearly every Sudoku help site. Those sites assume all values are possible and work to exclude. I work the opposite way; I only write down numbers that I can logically prove are a possible solution to a square, eventually one is proven correct.

Tbh I find Sudoku far too procedural; I used to challenge myself by solving the toughest puzzles in the books by using a pen rather than a pencil (which means you can only write in the grid when you have solved the value for a square and you can’t make a mistake), but even then it becomes more of a test of memory than logic.

I much prefer the Times deadly Killer Sudoku and Ultimate Killer Sudoku books as well as the Puzzler’s Killer Sudoku magazine as I find you have to be creative with your solutions.

But then I guess you haven’t really understood what level you are at.

You are only doing the A level by memory , because you were frustrated by your difficulty trying to make progress with all the information you MIGHT otherwise write down. Still doing it be memory didn’t help you progress further, to just gives you the excuse for why you didn’t.
The beginners level is

A1 Determine what '1’s tell you about where 1’s can be, by following how known 1’s block 1 from other places in the rows, columns and boxes.

A2 Determine what '2’s tell you about where 2’s can be,
A3 what 3’s say about 3 ,
etc

These were as simple as looking at a set of 3, If 9 is not in the first row, or the 2nd row, it must be the third row.. so set size 3..
Perhaps you missed two ideas

  • pointer pairs. If information from rows and boxes, told you about 1 being here or there in the same column, then that pair forms a pointer that blocks 1 from the rest of that same column.
  • blocking pairs, and blocking triplets. If n values must be in n places, they must be the only values in those places, and thus block those values ELSEWHERE. Because 'if x and y must be here or there ’ .. ‘therefore x and y must be the only values here and there !’..

Repeat through 1 to 9 looking for the set size 3 problem and answer.

But still many times you find ‘1 can be here or there’, but thats all you found about here or there. or the values don’t form pairs or triples ..this does not produce the idea of ‘it must be ONLY x or y’.

To do ‘must be only x or y’ you must look at set size 9.
Look at a place, and from the column, row and box, say ‘it must be only x or y or z’ . Can it be 1 ? no, can it be 2, yes, etc can it be 9 ? … etc. set size 9 logic

But still you might not have realise that by the time you have done set size 3 logic, you can intuitively identify where set size 9 logic would work best.
(because the row, column and box contribute blocking values so that the place has 8 values blocked … Or 7 or 6 values blocked is still possibly a good thing. Identify the n values in n places situations.. )

I don’t you’ve understood, I understand how to solve Sudoku puzzles.

The reason I did them by memory as I just don’t find Sudoku very challenging, most of the time you can solve it fairly quickly using procedural methods.

Just to test my recollection of how easy Sudoku is, I just picked up an old Sudoku magazine and attempted to solve the hardest puzzle I hadn’t already solved using a pen (i.e. only writing in a number once I’d solved for a particular square). Despite not even looking at a normal Sudoku puzzle for two years I was able to solve it in half an hour using this method (whilst i have to admit I did find it challenging, only from a memory p.o.v.).

Killer Sudoku is much, much better as the toughest puzzles require some genuine thought to solve.

I’ve seen questions like this before, and I don’t really understand them. They seem to posit a dichotomy between “solving using logic” and “solving via trial and error”. But solving via trial and error is one logical method of solution. It’s what, in more conventional math, would be called “reductio ad absurdem”. And if the goal is to solve it just using a pen, with no erasures, well, that just depends on how good your memory is: You don’t have to actually write down a “5” to say “what would happen if this was a 5 here?”.

I think the difference is between solving for the next entry using the numbers that are already known, versus solving for the next entry by (eventually) showing a contradiction.

In the first situation, the answer is found directly. No “memory” is required. Only one number satisfies the conditions on the board at that moment without the possibility of an eventual contradiction. That is not the case with the reductio ad absurdem approach.

In my opinion, only the simplest, easiest Sudoku are solvable “directly”.

All methods require some degree of memory. Let’s say that you’ve got a nice simple situation. Heck, let’s say you’ve got the simplest situation: All but one of the spaces in a block/row/column filled in. Your thoughts go something like “Can’t be a 1, there’s already one of those. Can’t be a 2, there’s already one of those. Can’t be a… Wait, could it be a 1? I can’t remember.”.

OK, so that’s a really easy thing to remember. But most people will think that there’s some qualitative difference between things that are easy to remember and things that are hard, when really, there isn’t. Worse, many people will draw that line at the point where they personally find it hard to remember and assume that that line is significant, when it isn’t at the same point for everyone.

I think KarlGauss had it right. Let’s take the extreme case of every box filled in except 1 blank. At this point, there is no memory needed, it’s all logic.

On the other hand, when I get stuck and have to guess, I have to remember the board state just before the guess so I can backtrack to it if a contradiction is found. I could photocopy the puzzle with my work to that point, which makes it trivial to backtrack to that decision point. I could take notes about the decision point. But I don’t want to do that or rely on memory. I want to move it forward with logic.

Will look at the Y-wing idea later, thanks for the suggestion.

I’m with Chronos. I don’t think there’s an objective distinction to be drawn of the sort people are proposing.

What would be an example of a “logical” move (not involving trial or memory) other than writing in the last value of a row, column, or box?

[And what distinguishes it as a basic move from moves such as “When you see the particular board so-and-so, fill in all the rest of the squares like such-and-such” which would reduce every puzzle to trivial logical solvability?]

Semantics. The OP mentioned getting stumped and resorting to guessing about a square. If you do that, you may have to fill out so much of the puzzle before an error shows itself that it’s impossible to do mentally so you have to fill out the boxes and it’ll probably be impossible to backtrack if the error does surface. Yes that’s trial and error, and some trial and error is necessary in sudoku, but not that kind.

When you’re stumped, you can keep looking at the puzzle from all angles until you find the solution. Or you can just pick a number and start filling in answers based on it. Call them both what you will, but the OP wants to do the first and avoid the second.

The hardest Sudoku puzzles are ones which require the use of a technique called “forcing chains”. You follow a chain of cells with only two possibilities each and eventually come to either a contradiction (one of the candidates of your starting cell would lead to a contradiction) or else show that both possibilities lead to the same result for some other cell. Some chains can be very long and spotting them isn’t always easy; it’s sort of like being able to demonstrate why a particular random guess doesn’t work.

http://www.sadmansoftware.com/sudoku/forcingchain.htm

I think, generally, when people want a logically solvable Sudoku puzzle, they’re talking about a puzzle with a unique solution given the clues. I’m not certain, but I’m fairly sure without going too deep into thought that these statements are equivalent. (I’m certain that a puzzle with no guessing must have a unique solution, but I’m not 100% sure off the top of my head that a puzzle with a unique solution must have no guessing, but I strongly suspect so).

There are some constraints on this. First, a Sudoku puzzle must have 17 or more clues, but that’s not sufficient. They also must be the correct 17 (or more) clues. Not every possible puzzle can be reduced to 17 clues (and still be unique), some require more, but it can be stated that any puzzle with less than 17 is certainly not uniquely solvable without guessing. The way to choose the clues has to do with ways to disambiguate similar rows/cols/squares, I believe, I’m not 100% clear on the method.

I don’t know how easy it is for a person to tell if a puzzle is uniquely solvable or not, though. Might make for a fun game if you’re bored though.
Here’s a video explaining why you need 17 clues minimum and a tiny bit about how they pick clues:

You determine uniqueness of solution to a puzzle by solving it. Go through and fill in as much as you can. Now take something that has a small number of possibilities (preferably only two), and check all possibilities for it. A few things might happen:

1: You might find that both possibilities lead to contradictions. In this case, the puzzle has no solution. Throw it away.
2: You might find that one of the possibilities leads to a contradiction, and the other leads to a solved puzzle with no contradiction in it. Congratulations; the puzzle has exactly one solution, and you’ve found it.
3: You might find that one of the possibilities leads to a contradiction, and you can’t carry the other one through to a full solution, but can’t find a contradiction either. Fill in the possibility that didn’t lead to a contradiction, and continue with a different set of possibilities.
4: You might find that one of the possibilities leads to a complete solution, and you can’t find either a solution or a contradiction in the other. There’s at least one solution and you’ve found it, but you don’t know if there are more. Take what you’ve got for the other possibility taken as far as you can, use it as your new grid, and start over with a new set to see if you can find more.
5: You might find that neither of the possibilities leads to either a complete solution or to a contradiction. Tough luck; try again with a different set.

This is equivalent to the backtracking strategy used by many algorithms, such as automatic test generation. I use all the tricks Isilder mentions, but in the Diabolical puzzles this is usually required. (If I think I need it in a Medium puzzle it means I made a mistake somewhere.)
The trick is in the selection of the “guess”. It should be a square where there are only two possibilities, and it should be one where the implication step forces values into many other squares, which increases the chances of a contradiction of the guess is incorrect. The worst cases are where the guess leads nowhere.
The way I do this is to circle the guessed number (in pencil) and then underline all squares filled in by implication - this makes backtracking fairly simple.

After looking the Y Wing technique, I find myself in the same camp as BwanaBob. I try to solve the Sudoku with a minimal amount of writing and erasing and in a minimal amount of time. So I first do a pass to determine squares that must be a unique value. Those I write in as a large numeral.

Then, I repeat until no more unique values are found. For the easiest puzzles, this is all that’s needed to solve it.

For harder puzzles, I have developed some general techniques that solves most of them. First, I determine if any subgrid has only 2 possible locations for a number and write those in as small numerals. Those solves many of the harder ones.

However, for a small fraction of those, I wind up with something that looks like the Forcing Chain situation. I fill in the remaining possibilities (numbers with more than 2 possible locations in a subgrid). This results in the same ambiguous state arrived at from the exclusion strategy.

In fact, one of the techniques described on that site is “Trial and Error”, which is precisely what I am faced with. It seems like there’s no choice but to take a guess.

I’ve analyzed the resulting solutions to see if there’s a general technique to get past the roadblock. It is possible to answer “why” one of the answers is correct with something like a Forcing Chain, but because there’s a large number of possible chains to check, those are difficult for me to spot unless I’m doing it after the fact.

BTW, thanks for the tip, Voyager. I use a similar way to backtrack, but your way is nicer.

There’s always more than one way to skin a cat.

A quite “logical” way to solve a Sudoku is to encode the puzzle as a Boolean expression. And run your favorite Satisfiability solver. (And if you don’t have one, just multiply out the CNF clauses.) May take awhile (after all it’s NP-Hard), but logical in an very formal sense.

I have no idea why people think that just because something can be solved by guessing, that it has to be solved by guessing.

Multiplying out all the CNF clauses is exactly the sort of brute-force search being described as guessing. I agree with you that it is logical, but others don’t. (Perhaps the distinction they would like to draw can be formalized at the level of algorithms, if not particular puzzles, in terms of computational complexity)