Logo
← Back to Blog

I Made a Sudoku Game in Blazor — Here’s Why That Was Fun (and a Bit Nerdy)

April 05, 2025

So, I built a Sudoku game. Why? Well... I like puzzles, I like code, and I wanted to see if I could combine those two into something fun, clean, and a little bit educational (for me and maybe for you too).

The origin of this project actually goes way back. I based the original game logic and structure on a book I read years ago — Programming Sudoku by Wei-Meng Lee. That version was written in VB.NET, and aside from the Windows Forms UI code, the entire game was crammed into a single file. Classic!

Instead of just copying it over, I took it as an opportunity to manually convert the code to C# and really get my hands dirty. I wanted to refactor it into a more object-oriented design, make the codebase cleaner, and implement design patterns like Strategy and State. I also practiced using Test-Driven Development (TDD) while breaking things apart — something I highly recommend if you're trying to bring legacy-style code into a modern, maintainable shape.

The Blazor app that wraps all this logic? That part’s brand new — all my own code. I have never built a Blazor project, so I thought this would be a great opportunity to learn. I also thought it would be fun to build a game in Blazor, and Sudoku turned out to be a perfect fit. Is it the best solution for a game? Definately not, but it was a fun challenge.

What’s This Blog Series About?

In the next few posts, I’ll break down how it all came together — the fun parts, the tricky bits, and the "wait, why is that not working?" moments. Here’s what’s coming up:

  • UI Stuff: How I got the Sudoku grid looking nice and behaving well in Blazor.
  • The Puzzle Model: Representing the grid, rows, columns, and logic in code.
  • Solvers Galore: How I used the Strategy pattern to plug in multiple solving algorithms (yes, it can brute-force too).
  • Game Flow: Managing states like "solving", "playing", and "done" using the State pattern.
  • Puzzle Generation: Randomizing puzzles that are actually solvable.
  • Deployment: Getting it live on the web without pulling my hair out.

I’ll also share some of the lessons I learned, like how easy it is to overthink a puzzle generator and how weirdly satisfying it is to watch your algorithm solve a board step-by-step.

Wanna Play?

You can try the game here:
Sudoku Game

If you’re into clean code, solving puzzles with logic, or just want to see how Blazor holds up in a small game project — stick around. I’ve got some fun stuff to share.