# Canonical Form for Sudoku

As described in the previous chapter, you can change a Sudoku in certain ways without changing its logic.

Therefore it is hard to compare two Sudokus. If you just compare them cell by cell you will find many pairs of Sudokus that seem to be^ differnt while haveing the same inner structure.

To solve this problem you can define a so called "caonical form", i.e. one that is the same for all isomorph Sudokus.

It goes like this: you write down all cells row by row, and you write a zero for all empy cells.

From this Sudoku:

You get:

000000010400000000020000000000050407008000300001090000300400200050100000000806000.

Then you define the canonical form to be **the isomorph
Sudoku that is the smallest when read as a single number**.

In this case the canonical form is

000000001000000020000003000000040500006000300007810000010020004030000070950000000

Or as an image:

There are programs that calculate the canonical form to a given Sudoku, for example YasSS.

top