Challenge 1: Sudoku
Let’s get on with the first coding challenge.
Problem statement
The problem has two tasks:
- First, you must initialize a grid representing a Sudoku board with all zeros.
- Second, you must implement the
assign()
function, which takes the following parameters:grid
: A list of lists.row
: An integer indicating a row on the grid.col
: An integer indicating a column on the grid.value
: Value be assigned.
This function should assign value
to the cell identified by row
and col
in the grid
. Make sure that it won’t alter any other values. The function should return an altered grid at the end.
Sample input
# Demonstrating a 3x3 grid, a 9x9 sudoku
# will also have similar inputs based on the dimensions
grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
row = 1
col = 0
value = 9
Sample output
# Output for the assign method for the above sample input
[[0, 0, 0], [9, 0, 0], [0, 0, 0]]
Get hands-on with 1400+ tech skills courses.