Using a List of Lists to represent the board

One of the first challenges in this type of program is how were are going to represent the board in code.

The board is a grid of 9 columns by 9 rows and each intersection forms a cell.

A cell will contain either,

  1. A number for a known cell
  2. A blank or a space
  3. A range of numbers 1 – 9 of possible values that may be in the cell.

This looks like a 2 dimensional array where we use x,y coordinates to specify a cell. The cell can then contain a list of possible values.

Python uses list for arrays and a list of lists for 2 D arrays.  So lets get our mind around that concept 🙂

Cab you now do this to simulate the full Sudoku Board of 9 x 9 grid ?

NOTE – Do not use the grid in the video above as a starting point. It is just for illustration and does not have a solution. (Thanks to Gillian Ward for spotting that one 🙂 )

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s