Back to Freecodecamp

Step 9

curriculum/challenges/english/blocks/learn-classes-and-objects-by-building-a-sudoku-solver/66069d65162e61357c793e0c.md

latest1.1 KB
Original Source

--description--

The sudoku puzzle to solve will be a list of lists, as the following:

py
[
  [0, 0, 2, 0, 0, 8, 0, 0, 0],
  [0, 0, 0, 0, 0, 3, 7, 6, 2],
  [4, 3, 0, 0, 0, 0, 8, 0, 0],
  [0, 5, 0, 0, 3, 0, 0, 9, 0],
  [0, 4, 0, 0, 0, 0, 0, 2, 6],
  [0, 0, 0, 4, 6, 7, 0, 0, 0],
  [0, 8, 6, 7, 0, 4, 0, 0, 0],
  [0, 0, 0, 5, 1, 9, 0, 0, 8],
  [1, 7, 0, 0, 0, 6, 0, 0, 5]
]

Note that the empty cells are filled with a zero.

Declare a puzzle variable and assign it the list of lists in the example above.

--hints--

You should declare a variable puzzle and assign it the provided 2D-list.

js
({ test: () => assert(runPython(`_Node(_code).find_variable("puzzle").is_equivalent("puzzle = [[0, 0, 2, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 3, 7, 6, 2], [4, 3, 0, 0, 0, 0, 8, 0, 0], [0, 5, 0, 0, 3, 0, 0, 9, 0], [0, 4, 0, 0, 0, 0, 0, 2, 6], [0, 0, 0, 4, 6, 7, 0, 0, 0], [0, 8, 6, 7, 0, 4, 0, 0, 0], [0, 0, 0, 5, 1, 9, 0, 0, 8], [1, 7, 0, 0, 0, 6, 0, 0, 5]]")`)) })

--seed--

--seed-contents--

py

class Board:
    def __init__(self):
        pass
--fcc-editable-region--

--fcc-editable-region--
gameboard = Board()