I have recently started making a sudoku solver. The solver itself is done and works great but i have found one issue. My solver is based on a 2D array that stores the sudoku game board numbers. The array looks like this....
The 12's represent empty spaces that need numbers in them.
private static int[][] currentPuzzle = new int[][] {
{ 12, 12, 6, 12, 12, 12, 12, 12, 12 },
{ 12, 12, 12, 12, 3, 6, 5, 12, 12 },
{ 2, 3, 8, 12, 12, 4, 12, 12, 12 },
{ 8, 7, 12, 12, 12, 12, 12, 12, 5 },
{ 12, 12, 3, 12, 9, 12, 2, 12, 12 },
{ 4, 12, 12, 12, 12, 12, 12, 6, 8 },
{ 12, 12, 12, 4, 12, 12, 8, 1, 9 },
{ 12, 12, 9, 3, 7, 12, 12, 12, 12 },
{ 12, 12, 12, 12, 12, 12, 6, 12, 12 } };
The problem is that my program reads the sudoku board integers from a game using the reflection java api. The method returns the sudoku board as a 1D array that looks like this....
The 12's represent empty spaces that need numbers in them.
private static int[] currentPuzzle = new int[] { 12, 12, 6, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 3, 6, 5, 12, 12, 2, 3, 8, 12, 12, 4, 12,
12, 12, 8, 7, 12, 12, 12, 12, 12, 12, 5, 12, 12, 3, 12, 9, 12, 2,
12, 12, 4, 12, 12, 12, 12, 12, 12, 6, 8, 12, 12, 12, 4, 12, 12, 8,
1, 9, 12, 12, 9, 3, 7, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 6,
12, 12 };
I need to convert the 1D array version(the second array shown above) of the board into the a 2D array version(the first array shown above) format. The new 2D array must have 9 rows with 9 columns.
Do you guys have any ideas?