Back to Freecodecamp

Step 10

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

latest1.2 KB
Original Source

--description--

Going back to the __init__ method, it requires an additional parameter representing the puzzle to solve.

Add a second parameter named board to the __init__ method and fix the instantiation of gameboard by passing it the puzzle list as you would pass an argument to a function call.

--hints--

Your __init__ method should have two parameters in the order: self, and board.

js
({ test: () => assert(runPython(`_Node(_code).find_class("Board").find_function("__init__").has_args("self, board")`)) })

Your gameboard variable should have the value of Board(puzzle).

js
({ test: () => assert(runPython(`_Node(_code).find_variable("gameboard").is_equivalent("gameboard = Board(puzzle)")`)) })

--seed--

--seed-contents--

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

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]
]

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