Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java program to create a 9 X 9 sudoku problem. A sample of a 9 x 9 sudoku board is given below: The
Write a Java program to create a X sudoku problem. A sample of a x sudoku board is given below: The rules for the sudoku game are: i Each row must contain the digits without repetition ii Each column must contain the digits without repetition iii Each of the nine x subboxes of the grid must contain the digits without repetition Procedure: Import java.util.Random package and use the nextInt method of the Random class to generate numbers between and for the sudoku board. For each row, take a number from the user between and both inclusive Then, randomly generate that number of distinct digits between and both inclusive and assign s to those corresponding cells of that row in the array. For instance, if the user types for the first row, then generate four distinct digits randomly using the nextInt method of the Random class. If the four digits are and then assign to and cells. Similarly, assign s to specific cells from the nd to th rows. These s will represent empty cells. Now, randomly generate distinct digits within the range to and assign them to empty cells of nine rows and nine columns as per the rules of the sudoku board. Repetition within a X block is allowed for this assignment. You dont have to check whether the sudoku is solvable or not. Hint: nextIntn method returns a digit between and n To generate a digit from to for a cell index, call nextInt method. To generate a digit from to use nextInt First, fill in the empty cells of nine cells of the first row and first column with distinct digits from to Then fill in the empty cells of the rest eight cells of the second row and second column as per the sudoku rule, and so on DO NOT use any arrayrelated builtin Java classes and methods. You can use the Scanner class of Java to read the user input. The sample input output is given below: points Sample input: Users inputs are shown in bold Enter the empty cell number from to for each row Enter the number of empty cells of row : Enter the number of empty cells of row : Enter the number of empty cells of row : Enter the number of empty cells of row : Enter the number of empty cells of row : Enter the number of empty cells of row : Enter the number of empty cells of row : Enter the number of empty cells of row : Enter the number of empty cells of row : Sample output:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started