Let’s write a sudoku

Shay Tavor
2 min readFeb 24, 2022

I love to play sudoku. I play it while I’m at the bus stop or waiting to pick up my kids from school… really, whenever I have some dead time.

Lately I ran out of sudoku boards in my sudoku application. Well, I know there are tones of apps out there, but in addition of loving sudoku, I’m also a programmer and I love to program. So I thought, why not writing my own sudoku application?

I’ve learned a lot from this experience, and I even recorded my process in an online course (link in the end), and I want to share my journey:

First thing first

Whenever we encounter a big challenge (in developing a software or any other field) it may be overwhelming — the number of things we should consider can be daunting and that for itself can cause us to “freeze” — we just don’t know where to start.

My solution to that — I always look for some small module in the whole project and try to develop it first. Of course it should be something that can be developed separately and with no dependencies in the rest of the project.

When dealing with the sudoku app (and games in general) I think the best place to start with is the game’s logic. My rule of thumb says that I code the game’s logic such that in the end I can play the game on the command line without any graphics. It’s not always practical for every application, but in the sudoku it works. So first thing to do — write a class that implements a sudoku game. It should generate a new sudoku board, be able to validate solutions and all other game’s rules.

Now what?

So we have a complete sudoku logic class. How to proceed?

Now it’s time to start writing the game’s manager which is the module that mediate between the UI and the logic.

It’s time to write a very basic UI. We don’t have to implement every aspect here, but we want it to be sufficient for presenting the board. Later on we’ll deal with the user clicks and dwell deeper into board manipulations.

Curious?

There are a lot of technical details that that involved and in a all, it’s not an easy project. But if you are curious, you’re invited to see my process of developing this game. I think it’s a great way to learn how to approach such a medium scale application and how to proceed.

You are invited to watch my course:

https://www.udemy.com/course/lets-create-a-sudoku-game/?couponCode=22EFD0A10CC4D0AA98D8

--

--

Shay Tavor

I’m an academic and freelancer instructor, teaching computer science and software engineering for more than 17 years now.