Showing posts with label Sudoku. Show all posts
Showing posts with label Sudoku. Show all posts

Wednesday, June 3, 2020

Miracle Sudoku

This video shows a guy named Simon Anthony solving a Sudoku puzzle with only two digits given. He and his partner have a very popular YouTube channel called Cracking the Cryptic. Anthony proceeds to solve the puzzle in about 20 minutes. His feat is impressive, especially with the extra rules he was given. In a common Sudoku puzzle, a solution cannot be unique with so few digits given. I have read that at least 17 or 18 digits are needed for that.  

Anthony’s full solution was as follows with the two given numbers in green.

483726159
726159483
159483726
837261594
261594837
594837261
372615948
615948372
948372615

His solution has recurring trios in the rows of every band and columns of every stack. For example, he entered 4 8 3 in rows 1-3 and 6 9 3 in columns 4-6. The order of digits within some trios aren't all the same. For example, there are 1 4 7 and 7 1 4 and 4 7 1.

I believed I might solve it faster using the copy and paste method I described in my May 27 post, with maybe a little tweaking after filling the grid.

The first digits I entered were as follows. I did the trio 2 6 1 first, then 4 8 5 and 7 3 9. 




























4 8 5 2 6 1


2 6 1





7 3 9


2 6 1



























Then I filled the rest of the grid as follows, which shows many recurring identical trios.


8 5 4 6 1 2 3 9 7
6 1 2 3 9 7 8 5 4
3 9 7 8 5 4 6 1 2
4 8 5 2 6 1 7 3 9
2 6 1 7 3 9 4 8 5
7 3 9 4 8 5 2 6 1
5 4 8 1 2 6 9 7 3
1 2 6 9 7 3 5 4 8
9 7 3 5 4 8 1 2 6

I finished this full grid in only 3 minutes, 36 seconds. It satisfies the king's move and knight's move rules. However, it violates the other extra rule. Pairs of successive digits appear next to one another, e.g. 1 2 and 4 5. I tried tweaking to get rid of them, but gave up after 20 minutes. 

Mr. Anthony's solution might be unique. Swapping rows 1&2 or rows 8&9 violate the knight's move rule. Hats off to him. 

Monday, June 1, 2020

Sudoku Making

I recently wrote three posts about how to start with a blank 9x9 Sudoku grid and completely fill it with numbers and no guesswork. I showed three basic methods. I thought of more since then that I won’t present. 

A Sudoku puzzle may be described as made of three 3x9 "bands" and three 9x3 "stacks," as demarcated by the lines in the grid below. More puzzles can be made from any full 9x9 grid by: 

- swapping two rows in a band
- swapping two columns in a stack
- reordering bands or stacks
- rotating the entire grid 90, 180, or 270 degrees 
- flipping the entire grid top to bottom or right to left
- transposing around the SW-NE diagonal or NW-SE diagonal. 

All of my methods produce a grid with recurring trios. Such recurring trios do not appear in solutions to puzzles I’ve seen made by others. That is, puzzles with blank spaces masking the full solution and available in newspapers or books, on the Internet, etc. Such recurring trios would also seem to make the puzzle easier to solve.

The following is the first puzzle I showed on May 17. There are recurring trios in the rows of every band, e.g. 3 6 9, and columns of every stack, e.g. 2 3 4.

1 4 7 2 5 8 3 6 9
2 5 8 3 6 9 4 7 1
3 6 9 4 7 1 5 8 2
4 7 1 5 8 2 6 9 3
5 8 2 6 9 3 7 1 4
6 9 3 7 1 4 8 2 5
7 1 4 8 2 5 9 3 6
8 2 5 9 3 6 1 4 7
9 3 6 1 4 7 2 5 8

The following is the second puzzle I showed on May 17, the one above after shuffling digits. It appears more random because 1 2 3 has been replaced by 6 4 7, and 3 4 5 by 7 2 8, and so forth. Yet there are still recurring trios in the rows of every band and columns of every stack. The digits are different, but the locations are the same. 

6 2 9 4 8 1 7 3 5
4 8 1 7 3 5 2 9 6
7 3 5 2 9 6 8 1 4
2 9 6 8 1 4 3 5 7
8 1 4 3 5 7 9 6 2
3 5 7 9 6 2 1 4 8
9 6 2 1 4 8 5 7 3
1 4 8 5 7 3 6 2 9
5 7 3 6 2 9 4 8 1

I have since found ways to eliminate the recurring trios by rearranging a few numbers in the grid. The logic for doing so is rather complicated, but not trial & error. After such rearranging, the scrambler I described on May 17, or the transformations described above, could be used with the grid to create more puzzles with no recurring trios.

Part of the logic is shown as follows. Suppose the top band looks like the following. (It is the first stack above transposed.)

1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6

Every row in the left box is repeated in the other two. Swap the numbers 3, 6, 9 in rows 1 & 2. The result would be as follows, with the changes made in green. The recurring trios are eliminated without violating any Sudoku rules. 

1 2 6 4 5 9 7 8 3
4 5 3 7 8 6 1 2 9
7 8 9 1 2 3 4 5 6


I suspect professional Sudoku puzzle makers use a different method involving trial & error. Example 1. Example 2. Whatever methods they do use are likely embodied in a computer program that could do all the trial & error very, very quickly. Do such programs screen for repeating trios? I suspect so.

By the way, every Sudoku solution I have ever seen has repeating pairs in 3x3 boxes aligned horizontally ("band") or vertically ("stack"). The following example is from here

9 2 8 1 6 7 5 4 3
1 7 5 4 9 3 2 8 6
6 4 3 2 5 8 7 1 9
8 9 6 3 2 5 4 7 1
3 1 4 8 7 9 6 2 5
7 5 2 6 4 1 9 3 8
2 3 9 5 8 4 1 6 7
5 6 1 7 3 2 8 9 4
4 8 7 9 1 6 3 5 2

The pairs 1,7 and 2,8 repeat in rows 1-3; the pairs 1,4 and 8,9 in rows 4-6, the pairs 1,6 and 2,3 in rows 7-9. The pairs 9,1 and 2,4 repeat in columns 1-3; the pairs 5, 9 and 2,4 in columns 4-6, the pairs 1,8 and 2,7 in columns 7-9. Such repeating pairs are impossible to avoid.

Wednesday, May 27, 2020

Simple Sukodu Maker #3

The following shows another method of making a completed Sudoku puzzle. This method involves no arithmetic, using copy and paste after filling in one 3x3 part of the puzzle with the numbers 1-9.

Start by putting the numbers 1-9 in any order in the top left 3x3 array (or block) of the 9x9 array. In the following B2-B9 are used to designate the other 3x3 arrays for ease of reference. B1 will refer to the top left 3x3 block of numbers.

7 1 2





3 5 6
B2

B3
8 9 4















B4

B5

B6



















B7

B8

B9











Next copy the first row of numbers in B1 to the 2nd row of block B2 and the 3rd row of B3. Then copy the 2nd row to the 3rd row of B2 and the 1st row of B3. The different colors in the following highlight the steps. Similarly but not shown, one could copy the 2nd row of B1 to the 1st row of B2 and the 3rd row of B3. Lastly copy the 3rd row of B1 to the remaining open row of B2 & B3. 

7 1 2 8 9 4 3 5 6
3 5 6 7 1 2 8 9 4
8 9 4 3 5 6 7 1 2










B4

B5

B6



















B7

B8

B9









Next copy the first column of numbers in B1 to the 2nd column of block B4 and the 3rd column of B7. Then copy the 2nd column of B1 to the 3rd column of B4 and the 1st column of B7. The different colors in the following highlight the steps. Similarly but not shown, one could copy the 2nd column of B1 to the 1st column of B4 and the 3rd column of B7. Lastly copy the 3rd column of B1 to the remaining open column of B4 & B7.

7 1 2 8 9 4 3 5 6
3 5 6 7 1 2 8 9 4
8 9 4 3 5 6 7 1 2
2 7 1





6 3 5
B5

B6
4 8 9





1 2 7





5 6 3
B8

B9
9 4 8






Complete the remaining blocks in similar fashion. One could copy (1) rows from B4 to B5 & B6 and rows from B7 to B8 & B9, or (2) columns from B2 to B5 & B8 and columns from B3 to B6 & B9.

One could also start by first putting the numbers 1-9 in any other 3x3 block and fill the remaining blocks following a method similar to the one used above. Whichever block is first filled, fill the other two blocks in the same 3x9 band and the other two blocks in the same 9x3 stack, or vice-versa.

Once the entire 9x9 array is filled, one could used the ranked random number process described in my May 17 post to make numerous more completed Sukodu puzzles. 

Friday, May 22, 2020

Simple Sukodu Maker #2

In my last post I showed how to make two simple Sudoku base puzzles. One started with entering the numbers 1 4 7 2 5 8 3 6 9 in the first row. It was completed by filling each column adding 1 to the entry above it, with the exception that 1 follows 9. The other started with entering the same numbers in the first column. It was completed by filling each row adding 1 to the entry to the left of it, with the exception that 1 follows 9.

Similarly, ten more almost as simple base puzzles can be made by adding 2, 4, 5, 7, and 8 instead of 1, with an exception -- if adding yields a number more than 9, then subtract 9 from the result.  Adding 3 or 6 doesn't work since they violate the Sudoku rule that each of digits 1-9 appears exactly once in each row, column, and 3x3 block. 

The following shows the puzzle made by filling the first row and then adding 4 in columns.

1 4 7 2 5 8 3 6 9
5 8 2 6 9 3 7 1 4
9 3 6 1 4 7 2 5 8
4 7 1 5 8 2 6 9 3
8 2 5 9 3 6 1 4 7
3 6 9 4 7 1 5 8 2
7 1 4 8 2 5 9 3 6
2 5 8 3 6 9 4 7 1
6 9 3 7 1 4 8 2 5

The following shows the puzzle made by filling the first column and then adding 4 in rows. It is also the above array transposed.

1 5 9 4 8 3 7 2 6
4 8 3 7 2 6 1 5 9
7 2 6 1 5 9 4 8 3
2 6 1 5 9 4 8 3 7
5 9 4 8 3 7 2 6 1
8 3 7 2 6 1 5 9 4
3 7 2 6 1 5 9 4 8
6 1 5 9 4 8 3 7 2
9 4 8 3 7 2 6 1 5

Like explained in my prior post, numerous more puzzles can be made from any of these 10 base puzzles using ranks of random numbers. 

More base puzzles could be made by swapping entire columns within the groups of columns 1-3, 4-6, and 7-9 and/or reordering the three 9x3 arrays. Similarly, more base puzzles could be made by swapping entire rows within the groups of rows 1-3, 4-6, and 7-9 and/or reordering the three 3x9 arrays.