ScratchData LogoScratchData
Back to abhayjoshi's profile

Sudoku solver

ABabhayjoshi•Created August 6, 2019
Sudoku solver
0
0
18 views
View on Scratch

Instructions

Click green flag and enter the puzzle. Input format is a single line as shown in the example below: 000020610,005300080,000500004,020600009,900702003,500009020,800004000,050008700,046030000, Press h for help (when the program is not asking for input).

Description

We will use what is called the "brute force" or "exhaustive search" approach. In this, we basically try all possible number combinations until the correct one is found. So, we start scanning the grid from top left and fill the first empty cell with a digit that fits (i.e. does not violate Sudoku rules) and then go to the next empty cell and fill it with a digit that fits, and so on. If a cell does not accept any digit, we go back to the previous cell that we filled and try a different digit in it. This process of "trial and error" and "backtracking" can go on for a very long time if done manually, but since computers are fast this "dumb" approach turns out to be quite practical and solves most puzzles in a few seconds. If you would like to see how I have designed this program, read this article: http://www.abhayjoshi.net/spark/scratch/blog/sudoku.pdf

Project Details

Project ID323318591
CreatedAugust 6, 2019
Last ModifiedApril 6, 2020
SharedAugust 6, 2019
Visibilityvisible
CommentsAllowed