Inspiration

The AI course I'm taking this semester motivated me to implement a backtracking algorithm with heuristics to solve a puzzle.

What it does

This code solves Sudoku puzzles. It will take a 9x9 matrix as an input and outputs a 9x9 matrix with the solution or indicates if a puzzle is unsolvable.

How we built it

I used Visual Studio and built in Java awt graphics to make the GUI. The algorithm is a backtracking method that uses a MRV heuristic to intelligently pick the most optimal box to fill.

Challenges we ran into

Tracking the recursive steps in the algorithm was difficult, as I had to visualize the steps the solve method was taking. Drawing a graph on paper to track variables and states was the most optimal way to visualize what the code was performing.

Accomplishments that we're proud of

I'm proud of the compactness of the code. I thought the project would take more files and many more lines, but I designed it efficiently enough that it only took 4 files with a few hundred lines.

What we learned

I learned more about how to use Java graphics and build a GUI using buttons and event listeners.

What's next for Sudoku Solver

I want to expand the algorithm to solve larger puzzles in 4x4 and 5x5 grids. Increasing the size will also increase the time and need for efficiency and more heuristics to make more intelligent inferences.

Built With

  • java
  • javaawt
  • javaswing
  • vscode
Share this project:

Updates