← 返回题库
中级

Sudoku Add To Copy

未完成
中级参考 代码结构已给出,请填写 ____ 处
# Write your solution here
def  solve(____):
    for i in range(____):
        for j in range(____):
            print(str(____) if sudoku[i][j] != ____ else '____', end='____')
            
            # Add an extra space after every ____ items
            if (____) % ____ == ____ and j < ____:
                print(____)
        print()        
        # Add a newline after every ____ rows
        if (____) % ____ == ____ and i < ____:
            print()
    

    

def copy_and_add(____):
     grid_copy = [row[:] for row in sudoku]
     
     grid_copy[row_no][column_no] = number

     return grid_copy

if __name__ == "____":
    sudoku  = [
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____],
    [____, ____, ____, ____, ____, ____, ____, ____, ____]
    ]

    grid_copy = copy_and_add(____)
    print(____)
    solve(____)
    print()
    print(____)
    solve(____)

示例

输入
solve(sudoku); solve(grid_copy)
期望输出
Original:
_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 

_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 

_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 

Copy:
2 _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 

_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 

_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _ 
_ _ _  _ _ _  _ _ _
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码