O'Reilly logo

Sudoku Programming with C by Giulio Zambon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 9

image

Implementing “Lines” Strategies

As I already said in Chapter 2, the lines strategies rely on parallel rows and columns. You can implement all lines strategies with three small functions named lines_2(), lines_3(), and lines_4() (see the respective Listing 9-1, 9-2, and 9-3) that set up the arguments for and then execute a generalized function named lines() (see Listing 9-4).

lines_2()

The idea is to form, one by one, all possible combinations of two line IDs and then pass them to lines() for processing. The number of possible line pairs is (C9,2 means: number of combinations of nine objects taken two at a time).

C9,2 = 9*8 / 2! = 36 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required