Online Sudoku
February 2022
Summary
This is an online version of the classic math puzzle Sudoku that I developed in Javascript with a backend in Node.js.
​
Puzzles are algorithmically generated in the following steps:
-
Ten random positions on the board are selected and assigned random values with the condition that the values be valid.
-
A recursive, backtracking solving function is then used to find a valid solution to the board. If no valid solution is possible, we clear the board and return to step 1.
-
Once we have a valid board, we call a function that removes entries from random positions on the board, one at a time.
-
After each entry is removed, we call the recursive solve function from step 2 to solve the board given its current state.
-
This function has a flag which lets us find all possible solutions. In this step, we want to verify that there is only one possible solution to the board's current state.
-
If the board is in a state where there are multiple solutions, we replace the most recent entry that we removed and continue by removing a different entry.
-
-
This function continues to run until it has removed a set number of entries that is determined by the difficulty that the player has chosen, i.e., a more difficult setting means the algorithm will remove more entries.
​
The player can navigate and enter values into the game board either by keyboard or by clicking on the game board and using buttons provided on the screen. The game also offers a "helper mode", which will display all the valid entries available to each empty square, given the current state of the board.
Motivation
This was my first substantional personal project that I worked on after spending a few months taking an online course in web development. My goals were to practice and consolidate what I had learned and get some sense of whether I would really enjoy working on software development full-time. In addition, I wanted to get some experience with web development in particular to see if that was a field I could see myself working in.
Takeaways
The overriding takeaway from completing this project was that I really enjoyed working on it and found myself motivated to make something that worked well and that I was proud of. This gave me the confidence that I had made the right decision to pursue a career pivot to full-time software engineering/development.
​
More specifically, I felt unsure about how much I enjoyed the front-end development aspects of the project. While I did find some satisfaction in developing a front end that I was reasonably happy with, given the state of my skills, I found the process to be tedious and frustrating. I much more enjoyed the work of developing the algorithms for solving puzzles and generating new ones, as well as the overall problem-solving aspects of the project, like how to implement the helper mode.
Opening Screen

-
There are four difficulty levels: easy, medium, hard and debug. The debug difficulty level leaves only a couple of entries blank. I used this mode for testing and debugging the game's behavior when a puzzle was solved.
Game In Progress

-
The orange square indicates the square that is currently active.
-
Black numbers are entries that are provided at the start of the puzzle.
-
For numbers entered by the user:
-
A purple number indicates that there are no conflicts detected.
-
This does not necessarily mean the entry is correct. It only means that the entry does not violate any of the rules of Sudoku, given the state of the board.
-
-
A red number indicates that the entry is currently invalid, i.e., the same number is present in the entry's row, column, and/or box.
-
This does not mean that the red number is incorrect. It simply indicates that it is in conflict with at least one other entry.​
-
When an entry is invalid, the entries that it is in conflict with will appear with a light red background.
-
-
Helper Mode

-
When "Helper Mode" is turned on, the empty cells will be populated with a grid of numbers showing which values can still be entered in that cell without creating conflicts.
-
Because the font has to be small enough to potentially fit nine numbers in the cell, the numbers can be difficult to read. To make it easier to quickly determine which numbers are still valid, the numbers are displayed in a 3x3 grid pattern within the cell.
-
For example, if 9 is a valid entry, it will always be displayed in the bottom right corner of the cell. Similarly, 5 will always appear in center of the cell.
-
Victory Screen

-
When the player solves the puzzle, a brief animation plays, revealing the victory screen.


