# 9 digit combos

Discussion in 'Probability and Statistics' started by bsbennett1, Mar 4, 2024.

1. ### bsbennett1

Joined:
Mar 4, 2024
Messages:
1
0
What would be the algorithm that produces all of the nine digit combinations using numbers 1 through 9, in which there are no repeating numbers and using a 3x3 array set up as depicted, once the number is used it can’t be used again.

#### Attached Files:

File size:
35.1 KB
Views:
4
• ###### array.png
File size:
22.3 KB
Views:
5
bsbennett1, Mar 4, 2024
2. ### RobertSmart

Joined:
Apr 9, 2024
Messages:
25
4
To generate all nine-digit combinations using the numbers 1 through 9 without repeating any number, arranged in a 3x3 grid, we can use a backtracking algorithm. Backtracking is a recursive algorithm that tries to build a solution incrementally and abandons a path as soon as it determines that this path cannot lead to a valid solution. Here's a step-by-step outline of the algorithm:

2. Track used numbers: Use a boolean array to keep track of which numbers from 1 to 9 have been used.
3. Backtracking function:
• If the grid is completely filled, print the grid or store the combination.
• Otherwise, for each cell in the grid (iterate row by row and column by column):
• Try placing each number from 1 to 9 in the current cell if it hasn't been used.
• Mark the number as used and place it in the cell.
• Recursively attempt to fill the next cell.
• If the recursive call fails to fill the grid, backtrack by removing the number from the current cell and marking it as unused.
4. Terminate the recursion: When all cells are filled, a valid 3x3 grid is obtained.
By the way, if you need further assistance with math assignments or want to explore more problems, you might find useful resources at website of MathsAssignmentHelp.com. You can contact them at +1 (315) 557-6473.

RobertSmart, May 17, 2024