Question: I don't know how to fix this code for it to print a sudoku puzzle with it saving the solution of the puzzle as a
I don't know how to fix this code for it to print a sudoku puzzle with it saving the solution of the puzzle as a corresponding array. The code is in Java.
public class Sudoku
intmat;
int N; number of columnsrows
int SRN; square root of N
int K; NoOf missing digits
Constructor
Sudokuint Nint K
this.N N;
this.K K;
Compute square root of N
Double SRNd MathsqrtN;
SRN SRNdintValue;
mat new intNN;
Sudoku Generator
public void fillValues
Fill the diagonal of SRN x SRN matrices
fillDiagonal;
Fill remaining blocks
fillRemainingSRN;
Remove Randomly K digits to make game
removeKDigits;
Fill the diagonal SRN number of SRN x SRN matrices
void fillDiagonal
for int i ; iij
fillBoxii;
Returns false if given x block contains num.
boolean unUsedInBoxint rowStart, int colStart, int num
for int i ; iN && iN && jN
return true;
if i SRN
if j SRN
j SRN;
else if i NSRN
if jintiSRNSRN
j j SRN;
else
if j NSRN
i i ;
j ;
if iN
return true;
for int num ; numN; num
if CheckIfSafeijnum
matijnum;
if fillRemainingij
return true;
matij;
return false;
Remove the K noof digits to
complete game
public void removeKDigits
int count K;
while count
int cellId randomGeneratorNN;
Systemout.printlncellId;
extract coordinates i and j
int i cellIdN;
int j cellIdN;
Systemout.printlnij;
if matij
count;
matij;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
