Skip to content

Add Sudoku backtracking algorithm #2666

@nyctophiliacme

Description

@nyctophiliacme

Is your feature request related to a problem? Please describe.
Yes, it is related to the Sudoku problem. Given the sudoku puzzle of a 9×9 2D array, the goal is to assign digits (from 1 to 9) to the empty cells so that every row, column, and subgrid of size 3×3 contains exactly one instance of the digits from 1 to 9.

Describe the solution you'd like
Assign a number to cell and recursively check whether if this assignment leads to a solution or not. If the assignment doesn’t lead to a solution, then try the next number for the current empty cell.

Describe alternatives you've considered
The simple approach, without backtracking is to generate all possible configurations of numbers from 1 to 9 to fill the empty cells. Then check if the solution is valid or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions