I am writing a Sudoku code in Java.
I already wrote a code, but instead of columns, rows are switched!
int[] tempField = array2D[myFirstCol_toSwitch];
array2D[myFirstCol_toSwitch] = array2D[mySecondCol_toSwitch];
array2D[mySecondCol_toSwitch] = tempField;
In order to generate a Sudoku board I need to swap columns randomly.
The entries of a column are distributed across all the rows, one item per row. So in order to swap two columns, you have to loop through all the rows and swap the appropriate items in each row, like this: