3
$\begingroup$

I'm attempting to write a program that solves Sudoku puzzles using a variety of techniques. Up this point, I've only implemented naked singles and hidden singles (for rows and columns). I've been trying to implement the Skyscraper technique, but when solving by hand, I've been having trouble getting it to work particularly for this puzzle:

enter image description here

The program solves it up to this point:

enter image description here

When I attempt the following Skyscraper by hand, I eliminate the 9 for a naked 5, and thus fill it in...

enter image description here

But the completed puzzle is as follows...

enter image description here

Why is this? Is there some parameter of the Skyscraper technique that my structure isn't meeting? What about in the following case, where I create a Skyscraper structure under just about the same conditions as the first scenario, thus yielding a naked 7, which is the correct value for the green cell. How come the first Skyscraper didn't work?

enter image description here

$\endgroup$
  • $\begingroup$ What's wrong with the completed puzzle? $\endgroup$ – greenturtle3141 Oct 30 '16 at 19:54
  • 1
    $\begingroup$ Those aren't skyscrapers. A skyscraper means the red cells are the only two cells in their respective columns to contain a 9 as possibility. But there are more cells in their columns that contain a 9. In the 2nd example, same thing: the red cells aren't the only ones that contain a 7. It's not a skyscraper. $\endgroup$ – Dennis_E Oct 30 '16 at 20:31
  • $\begingroup$ @Dennis_E Thank you for your input. I see now why they are not skyscraper structures! $\endgroup$ – Zulfe Oct 30 '16 at 20:59
  • $\begingroup$ With all these techniques, it's important to understand why you can eliminate numbers. $\endgroup$ – Dennis_E Oct 30 '16 at 21:09
5
$\begingroup$

I think that

For a skyscraper (a type of x-wing) the values ($9$ in this case) must only occur twice amongst the pencil marks in two rows (or columns).
Hence your "by hand" execution is incorrect

Also note that there is

a hidden single $7$ in the top row, fourth column (only 7 left in the nonet) which your solver should find first.

And that

using only hidden and naked singles should get to this point: 6 1 2 | 7 . 8 | . . . 9 5 3 | 4 1 2 | 6 7 8 8 7 4 | 3 . 6 | . . 1 ------+-------+------ 2 8 1 | 5 6 . | . 9 . 4 9 7 | 2 8 3 | 1 6 5 5 3 6 | 1 . . | 8 . . ------+-------+------ 3 2 8 | 6 7 . | . 1 9 7 6 . | . . 1 | . . . 1 4 . | . . . | 7 . 6
whereupon you should find three different naked pairs (something you don't say you've implemented but which is simpler) removing pencil marks for $5$ and $9$ from four of the cells in the lower half. The naked pair of the $5,9$ in the middle column leaves a naked single $4$ in the sixth row, middle column, whereupon naked singles will finish to the solution posted.

$\endgroup$
  • $\begingroup$ Thank you so much for your answer! I've yet to implement the finding of hidden singles in blocks, which clearly needs to be done. I'll also look into naked pairs! $\endgroup$ – Zulfe Oct 30 '16 at 21:00
  • $\begingroup$ See sudokuwiki.org for a similar type of solver (logical, pattern based step by step), and a strategy overview (which does not have "skyscraper" itself). Even that solver wont solve some sudoku. There is a program called SudokuExplainer which will - but the end result for very tough sudoku is fairly long inference chains. A member here, 2012rCampion also has created a solver which only does that and I have created one which gives no reasoning (using dancing links). $\endgroup$ – Jonathan Allan Oct 30 '16 at 21:09
  • 1
    $\begingroup$ You can see the set of deductions my old Sudoku solver made for this problem here. $\endgroup$ – David Schwartz Oct 30 '16 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.