I enjoy solving Sudoku Puzzles. To an extent where some would call it an obsession.

**For the non - Sudoku - aficionados :** Sudoku is a number based logic game invented in Japan. It has a set of 9 x 9 "cells" (9 rows and 9 columns), where each cell is filled with a number between 1 to 9. The number solutions should follow a few rules:

- Rule Number 1 : The same number cannot appear more than once in a row
- Rule Number 2 : The same number cannot appear more than once in a column
- Rule Number 3 : The same number cannot appear more than once in a "mini-grid". (Every 9x9 grid is divided into 9 3x3 "mini-grid"s). In the snapshot below, every grid marked in 3 by 3 would be a mini-grid.

There are variations to this game where additional rules are added. Example - Sudoku X is a variation where an extra Rule is added that no number can repeat on the diagonal of the Sudoku Board.

Now that **you know what Sudoku** is,

A couple of weeks back, while solving a game on the newspaper, i was explaining to a friend the steps i follow. When i wanted to demonstrate the steps visually i checked multiple websites but i did not find an engaging experience.

Further, when searching for Sudoku solving algorithms, i observed that most of them use a "brute force" method to solve the puzzle. Logic for bruteforce - Attempt to force fit a number in a cell. And then the next, and next and so on. At any point, if while putting the number if it is decided that the above mentioned rules of Sudoku are broken, back trace and try the next possibility. Though this solves the puzzle, i felt that it does not help me in demonstrating the steps of solving the puzzle using logic thinking.

And so i decided to build one. One which cues the steps for deducing the values . The logic for the solution turned out to be simple to code, and I got it coded over a weekend. But the niceties of UI and "visual" cues took longer. Self Reminder Note - ReactJS is not the best choice for displaying visual cues such as a flash "animation" for a cell.

Do give it a try at https://samples.sachinnayak.info/visual-sudoku-solver.html .

Note : The logic applied still does not work with Expert level Puzzles. I have yet to code the logic for the expert level. Any help appreciated. Code available on my github repo (https://github.com/psachinnayak/psachinnayak.github.io).

Comments powered by Talkyard.