Sudoku Challenge in Small Basic

All replies

• This is my first step: RQM589.

This program is just a Sudoku UI.  You can hit arrow keys (or click) to select a cell.  And hit number keys, [Back Space] or [Delete] to set/reset a number.

Usage:

1. Set numbers to initialize puzzle yourself.
2. Push [Solve] key to start solving yourself.
3. Set numbers to solve the puzzle.
4. Push [New] key to clear all numbers.

Nonki Takahashi

Wednesday, June 19, 2019 2:39 PM
• The second step will be thinking how to generate Sudoku puzzle.

Nonki Takahashi

Tuesday, June 25, 2019 10:44 PM
• This is a simple idea to generate Sudoku puzzle: FJJ051.  This idea fills random number from top left to bottom right.  But random number is selected from candidate numbers that are updated with filled numbers.  If there is no candidate, it restarts from the first.  Following text is a sample output of this program.  The left side means the generated puzzle and the right side means remaining candidates as 9 bit hexadecimal (000-1FF).

```7 9 6 1 5 3 2 8 4  004 001 008 100 010 040 080 002 020
3 8 1 7 4 2 9 5 6  040 002 100 004 020 080 001 010 008
4 5 2 9 6 8 7 3 1  020 010 080 001 008 002 004 040 100
9 3 8 2 1 4 5 6 7  001 040 002 080 100 020 010 008 004
6 7 5 3 8 9 1 4 2  008 004 010 040 002 001 100 020 080
1 2 4 5 7 6 8 9 3  100 080 020 010 004 008 002 001 040
5 6 9 4 2 7 3 1 8  010 008 001 020 080 004 040 100 002
8 1 7 6 3 5 4 2 9  002 100 004 008 040 010 020 080 001
2 4 3 8 9 1 6 7    080 020 040 002 001 100 008 004 010

i = 81
row = 9
col = 9
n = 5
7 9 6 1 5 3 2 8 4  004 001 008 100 010 040 080 002 020
3 8 1 7 4 2 9 5 6  040 002 100 004 020 080 001 010 008
4 5 2 9 6 8 7 3 1  020 010 080 001 008 002 004 040 100
9 3 8 2 1 4 5 6 7  001 040 002 080 100 020 010 008 004
6 7 5 3 8 9 1 4 2  008 004 010 040 002 001 100 020 080
1 2 4 5 7 6 8 9 3  100 080 020 010 004 008 002 001 040
5 6 9 4 2 7 3 1 8  010 008 001 020 080 004 040 100 002
8 1 7 6 3 5 4 2 9  002 100 004 008 040 010 020 080 001
2 4 3 8 9 1 6 7 5  080 020 040 002 001 100 008 004 010

Press any key to continue...```

This method is slow.  So I'd like to improve the performance.

Nonki Takahashi

Wednesday, June 26, 2019 2:04 PM
• We already have some Sudoku Solvers written in Small Basic.

This challenge is to write Sudoku puzzle generator in Small Basic.  Let's try!

Nonki Takahashi

KFT931 does not import. wrong id?
Friday, June 28, 2019 4:17 AM
• Hi Tryhest, thank you for your feedback.  KFT913 is the correct id.

Nonki Takahashi

Friday, June 28, 2019 7:26 AM
• updated chaos sudoku: WWM385

• english translated
• on import must be removed autorem clauses 'The following...' in order to run
• use regular instead of numeric keys 1-9
• use Q W to undo/redo

• Edited by Sunday, June 30, 2019 6:21 AM
Sunday, June 30, 2019 6:15 AM
• My rough idea to generate Sudoku puzzle is:

1. Generate a Sudoku solution.
2. Randomly remove a number from the board.
3. Run Sudoku solver to the new board.
4. If solved, repeat from step 2.
5. If not solved, restore last removed number.

This algorithm needs a Sudoku solver.  So I wrote it: GXT523.

Nonki Takahashi

Friday, August 16, 2019 4:20 AM
• I rewrote Sudoku solution generator to call Sudoku solver.  The new one is KSZ955-1.

I also wrote a new program Sudoku Hint Reducer.  This tool reduces hints from Sudoku solution.  The program ID is ZMP623.

Nonki Takahashi

Saturday, August 17, 2019 9:44 AM
• The third step is NTS300.

Nonki Takahashi

Wednesday, August 21, 2019 4:46 AM
• The fourth step: NTS300-0.

• You can solve the puzzle with number keys, arrow keys and Delete or Back Space key.
• You can toggle note with Ctrl + number keys.
• [Next] button is for next puzzle.
• No reaction when you solved...
• There is no hidden pair check in SS_ReservedPair().

Nonki Takahashi

Saturday, August 24, 2019 10:21 AM
• I found a good site to understand how to solve Sudoku.
Angus Johnson's step-by-step guide to solving Sudoku (2005)

Nonki Takahashi

Friday, September 13, 2019 1:19 AM