Sudoku Fundamentals - a New App for the iPad

Programs which generate, solve, and analyze Sudoku puzzles

Sudoku Fundamentals - a New App for the iPad

Postby nedBlake » Thu May 26, 2016 12:49 am

      { edited by Moderator
      to include links }
The website has a link to Sudoku Fundamentals on the App store where you can view several screenshots (best viewed on an iPad where you can enlarge them), and a description related to the screenshots. The following is a brief overview of what this app provides:

A library of puzzles graded in four levels from "Easy" to "Extreme".

The Fundamentals: Thirty screens of simple examples and text describing the strategies needed to solve puzzles at each of the four levels. The examples show how these strategies follow logically from fundamental statements based on the Sudoku rules.

The ability to create puzzles (see post "Using the Sudoku Fundamentals App to Create Puzzles"). A fast solver allows a different approach.

A Grader that assigns a level to a created or imported puzzle based on the strategies needed to solve it.

Puzzles can be exported to a web solver for help in solving them.

Visual aids appropriate for each level are provided. At the Extreme level, a draw mode allows the user to draw links between possible solutions on the screen. A faint trial line turns into a solid or dashed line, or disappears, depending on whether the link is strong, weak, or doesn't exist.

The price for this app has been reduced to 99 cents.
2017 Supporter
Posts: 12
Joined: 08 May 2016

Using the "Sudoku Fundamentals" App to Create Puzzles

Postby nedBlake » Thu May 26, 2016 12:53 am

The following is referred to by the post "Sudoku Fundamentals - a New App for the iPad", and gives some background on that App's approach to puzzle creation.

If you use the Create action keypad to enter the following:
1 2 3 4 5 6 7 8 9
4 5 6 1
you would see the "1" in the second row show up in red, meaning that it is not acceptable. The "1" is perfectly legal here according to the rules of Sudoku. But as a message tells you, placing a "1" here will cause the puzzle to be not solvable.

This happens because the solver is called as each number is entered. This is useful when transcribing a puzzle from a newspaper, as you will likely be told if you enter a wrong number or put it it in the wrong cell. And if you are told that you have "multiple solutions" after you finish, then you know you left a number out.

But it also makes it possible to create a puzzle manually. You could enter a number anywhere, and if it didn't follow the rules of Sudoku or, as in this case, led to a non-solvable puzzle, you could just enter some other number until you got it right. You didn't need to even "undo" the wrong number, since it wasn't accepted.

At some point you will be told that you have created a puzzle with a single solution. You will even be told the grade ("Easy", "Moderate", "Hard" or "Extreme"), because this solvable puzzle is sent to a grader which determines the difficulty of the puzzle by finding the highest level strategy described in the "Fundamentals" necessary to solve the puzzle.

But what you have is probably an "Easy" puzzle with a lot of unnecessary clues. At this point, you would need to go around and use the space bar to delete clues. You would need to undo the delete if you were told, after the delete, that you now had multiple solutions.

All of this would be a lot of work. The next step was obvious. Automate this whole process by using Random and Trim. Random chooses a random empty cell and a random number to put in it, and calls the same code that was called when you used the keypad. If the number is not valid, it chooses another cell-number pair. This continues until the solver tells Random that it has a single solution. It then returns with a message telling you the grade of the puzzle.

Trim automates what you were doing with the space bar. It randomly searches for a cell that has a clue that it can delete because it is unnecessary for finding the solution. It deletes it and tells you any change to the puzzle grade.

There were two ways in which the quality of a puzzle was improved. The first was by distributing clues evenly. This was accomplished in the Random action by first choosing cells that see the least number of clues in units containing that cell. The companion Trim action contributed by first removing clues from cells seeing the most other clues in units containing that cell.

Another way is through the use of a "Protect Pattern" (an example is the 2nd screenshot in the App Store description), which determines, in a negative way, the clue pattern. It specifies areas which random selection should not invade but manual input can. If this Protect Pattern is not used, or if it is not too restrictive, clues will be distributed evenly as described above.

Several different patterns have been tried, including those used by newspaper puzzles. These puzzles often have a pattern consisting of opposing blocks rotated 180 degrees from each other, which were originally thought to possibly have some magical effect in producing good puzzles. It was later discovered that these patterns came about by starting with a totally solved randomly generated puzzle, and removing numbers from diagonally opposite cells. Thus the puzzle determines the pattern, instead of the pattern determining the puzzle. The newspaper pattern makes a reasonably good puzzle if the pattern is modified to provide even distribution.

Using a pattern is computer intensive. If the protected area is so restrictive that Random can't provide a solvable puzzle without invading the protected area, it gives up after 60 tries, which takes a little over a second (on an iPad mini). This consists of over 1300 solver calls, giving an average solve time of about 1 mSec.

Although geometric patterns can be fun to solve, some of them do not make good puzzles. But in general, evenly distributed clues result in good puzzles, whether this is forced by a pattern or determined by the algorithm as described above. A check for some things that make a puzzle "good" can be automated, but as of now puzzles were mostly tried out before being included in the library.

There are ways a user can tailor a puzzle to his or her liking. Suppose that you would like to create a Moderate puzzle. The Random action by itself will probably give you an Easy or Moderate puzzle to begin with, which then needs to be trimmed. Trimming an Easy puzzle usually gives you a Moderate puzzle, although it sometimes ends up with a Hard or Extreme one. You could undo Trims until you get back to a Moderate level, but at this point it's better to Clear the puzzle and select Random again.

Your completely trimmed Moderate puzzle will probably have clues numbering in the low 20's. This means that your rows, columns and blocks will mostly have 3 entries, with a few of them having only 2. This is tough if you don't like to use the Moderate option that fills empty cells with possible solutions. But you can now use Random again, which will then probably add a clue to one of the units with 2 entries. Random does this because it doesn't know that you have a single solution, and it doesn't check for a single solution until after it has added a clue.
2017 Supporter
Posts: 12
Joined: 08 May 2016

Sudoku Fundamentals is now FREE

Postby nedBlake » Wed Jun 22, 2016 5:55 pm

Release 1.2 is free, including the full library of several hundred puzzles, no ads, and no crippled functions that you have to pay to "uncripple".

You need to search the Apple App store for "Sudoku Fundamentals". "nedBlake" also works, as this is the only app that I have written.

With this Forum in mind, I have changed the "Import" action to look for only the numbers 1 thru 9 and the period (for space). All other ascii codes are ignored, so if you are able to select an area where these characters appear only in the puzzle grid and not elsewhere in the selected area, then you will import what you want.

The daily puzzles that show up in Puzzles are fairly easy to copy. When imported, these puzzles are often graded as "Extreme", since they contain this level of chains and cycles. If you need help, you will find the Fundamentals topic "Introducing Links and Chains" helpful, where several examples show what they all have in common. Then start playing around in Draw mode, and you will soon become an expert.

I particularly like the variety of patterns that you find in The Superior Thread of the Sorted Puzzle Collection. In this case, I found it difficult to make Safari select what I wanted, and ended up selecting the whole thread and pasting it into a text file on my iPad, from which it was alot easier selecting individual puzzles.

You will notice that the Import action in my app has a "Create Protect Pattern" button. The purpose of this was to provide a way to save patterns that you created by saving the puzzle that was created using that pattern. When you Imported that puzzle, you could then re-create the pattern from the puzzle, and then clear the puzzle so that you could then create more puzzles with that pattern.

And so "Create Protect Pattern" really wasn't intended to be used for stealing patterns from other peoples puzzles, but it certainly works well doing just that. (But I don't believe patterns can be copyrighted.) I was able to create several really good Moderate puzzles from these patterns which are now in the library. If Random is not able to keep out of the protected area, you will need to touch Clear twice and try another Random run, and you may need to change the protected area by using the "Cell" button.
2017 Supporter
Posts: 12
Joined: 08 May 2016

Major functional improvement to Grader in Release 1.4

Postby nedBlake » Mon Nov 14, 2016 2:47 pm

The Grader originally assigned one of four grades to a puzzle, based on its ability to solve a puzzle by applying the strategies described in the Fundamentals. Actually it only applied strategies from the first three sections of the Fundamentals ("Easy", "Moderate" and "Hard"), and if these weren't successful, then it assigned the grade of "Extreme".

This grade was used to assign a puzzle to a particular library.

The first improvement in this release consisted of implementing the "Extreme" strategies, which essentially consist of different forms of chains that imply a particular possible solution cannot exist, or that a certain possible being or not being a solution leads to a contradiction.

The second improvement, which was easier to implement but probably more important, is the collecting of statistics on which strategies were used, and then assigning three "difficulty" levels within each library level based on these statistics.

These levels are denoted by stars. An Easy*** puzzle is guaranteed to be able to be solved using only the strategy of "Rows and Columns Crossing Blocks", because that is the only strategy necessary to solve any Easy puzzle. But the 3 stars means that you will have to apply that strategy many times, and it may take you awhile.

Assignment of stars to a "Moderate" puzzle is more difficult. Right now it is being determined mostly by the nTuples (pairs, triples, quads) found, each having different weight, and the ratio between this sum and the number of naked singles found that are not directly related to finding an nTuple. If there are a lot of these naked singles compared to nTuples, then the puzzle gets fewer stars, and perhaps discarded. Assigning stars to Hard and Extreme puzzle is a little easier, as it is related mostly to the type of strategies needed to solve them, and such things as chain length. Extreme level puzzles may have four stars, which mean that a strategy not described in the Fundamentals was needed, or solution time was just too long and the Grader gave up.

These statistics are also useful in that they may give you some idea of the "goodness" of a puzzle. There is now a backdoor way of setting a switch causing the display of an abbreviated line of these statistics in the user message field when a puzzle is being created or has been loaded. I'm thinking about making display of these statistics an option in the next release, but not sure it would be worthwhile. If you want to use the current crude "backdoor" way to display them, let me know and I will post it here.

On another subject, I was happy to see that there are now some people actually downloading "Sudoku Fundamentals" from the Apple store. I suspect that most or all are by members or viewers of this forum, as they happened after I made posts here.
Also my app is almost invisible in the store. If you search for "sudoku puzzles" or "free sudoku puzzles" you won't find it. Apparently, if no one has reviewed your puzzle, Apple figures it's not worth mentioning. So I would really appreciate reviews, even just a couple of words.
2017 Supporter
Posts: 12
Joined: 08 May 2016

Sudoku Fundamentals Release 2.0

Postby nedBlake » Thu Feb 09, 2017 9:15 pm

This release provides an obvious next step. The last release introduced a Grader that assigned stars to a puzzle that you created or loaded from a library, based on which strategies were needed to solve it, and how often each strategy was used.

But there was no way to select a puzzle having a given number of stars. In this release, after you select a library, you can choose one, two, or three stars. If you select the "Extreme" library, you will see an additional 4-star button, which will give you a puzzle that the Grader was unable to solve, either because the strategy is currently not described in the Fundamentals, or because it was taking the Grader too long to solve it.

By default, a summary of the strategies that were used by the Grader for the final level, and at least the first pass through each lower level, is displayed in a scrollable list.

Also, an "Invert" button was added to the Create screen, which made it easier to create a pattern when the puzzle is meant to take on the shape of the pattern. In the following, a protect pattern in the shape of a heart was first drawn using Protect/Cell. The Invert button then changed the puzzle by making the protected cells unprotected and everything else protected, The Random action, which must avoid the protected area if possible, is forced into using the heart-shaped unprotected area.

rel 20 forum photo1 final.png
rel 20 forum photo1 final.png (24.27 KiB) Viewed 70 times


Import can lift the pattern from this puzzle, and then you can Clear it and use Random to create a sudoku having this pattern. But with unprotected cells in the low 20's, be prepared to have to use Random several times. Random is likely to invade the protected area, and then you have to use Clear twice: the first use clears the unprotected area and the second the protected area.

In the following, the protected area is used differently. In this case, the beginning of a puzzle is entered manually into a protected area (or it can be entered first and then protected, or it can be an existing puzzle where part has been protected and the rest of the puzzle has been cleared). Manual entry is made easy, as the Solver won't let you enter a clue that doesn't lead to a solvable puzzle. Random here has plenty of unprotected cells to use. Note that clues are distributed evenly, since that option was in effect.

rel 20 forum photo2 tot.png
rel 20 forum photo2 tot.png (25.82 KiB) Viewed 70 times


This puzzle was graded as Extreme since it required a chain, although a very simple one, in order to solve. If you scrolled the Grader statistics, you would see the following:

(Easy 1st pass) clues:25 blockChecks:1
(Moderate 1st pass) E* nS:2 nP:3 nT:3 nQ:2 hM:0 hS:0
(Hard 1st pass) E* M** int:0 Xwng:1 Ywng:0 XYZwng:0 Rcyc:0 RCgrd:0
E* M** H** Schain:1 Mchain:0 Cchain:0 maxLength:4

The E*, M** and H** represent grades that the puzzle would have received if the Grader had been successful in solving the puzzle at the end of the 1st pass of the Easy, Moderate and Hard levels.

The above abbreviations are discussed at the end of the Fundamentals "Creating Puzzles" topic, so I won't go that much into it here, other than to say that for this puzzle:

Easy level: one productive check for rows/columns crossing blocks.
Moderate level: 2 naked singles, 3 naked pairs, 3 triples, 2 quads.
Hard level: 1 Xwing.
Extreme level: 1 single-possible chain.

This is for the first pass only. An improvement is planned to report strategies used for all passes.

Some of what is reported is for information only and does not affect the grade. For example, the number of naked singles, which are not even reported if they were revealed by an nTuple, is mostly the result of singles that became obvious after "All Possibles" were shown at the Moderate level. If you see many of these and little or no nTuples found, then you know that using "Show All Possibles" would be a mistake.
2017 Supporter
Posts: 12
Joined: 08 May 2016

Release 2.1 - mostly minor improvements

Postby nedBlake » Sat Mar 18, 2017 1:56 pm

A thread problem was fixed which caused a "processing" message not to be displayed while a puzzle was being created.

As it stands now, the default of the "Show Grader statistics" option is to display them. This has been changed to not display them, as the abbreviations used are kind of cryptic and a user might wonder what they are all about. By making the user turn on the option, the option description at least tells the user where he can find a description of the abbreviations.

Libraries were updated. In particular, several 4-star puzzles were added to the "Extreme" library. The 4 stars indicate that the Grader could not solve the puzzle, which usually means that the Grader would need strategies beyond those described in the Fundamentals in order to solve them. (For those of you that like a challenge.)
2017 Supporter
Posts: 12
Joined: 08 May 2016

Return to Software