Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( Please read requirements of the program carefully screenshot your output ) Write a Java program that performs the following tasks: Display a friendly greeting

(Please read requirements of the program carefully screenshot your output )
Write a Java program that performs the following tasks:
Display a friendly greeting to the user
Prompt the user for a filename (if the file wasnt provided on the command line)
Accept that filename
Attempt to open the file
Read the 81 numbers in the file and populate a 9x9 table with them
Note: the char * or - is used to designate an empty spot
because 0 is a valid entry in the hexoduko puzzle
Display the contents of the file
Solve the puzzle using the algorithm given
Display the solved puzzle, or an appropriate message if no solution is found
The rules of Sudoku:
The integers 1-9 appear in a 9x9 grid. The grid is subdivided into nine 3x3 subgrids.
The thee Sudoku constraints are:
Each digit 1-9 appears in each row, without omissions or duplicates
Each digit 1-9 appears in each column, without omissions or duplicates
Each digit 1-9 appears in each 3x3 subgrid, without omissions or duplicates
Diagonal Rule Sudoku adds a fourth constraint:
Each digit 1-9 appears in each of the two long diagonals, without omissions or duplicates.
The isValidPuzzle method need check only these constraints; if they are satisfied, well call it a valid puzzle.
The input file will be 81 integers, space-delimited. Test your program with a variety of Sudoku puzzles. They are easily found on the net. How long does it take your program to solve the Worlds Hardest Sudoku? Or an empty puzzle?
Note that if you get the regular version working, the Super version only differs by a few lines in the isValidPuzzle method. However, be careful how you test it; most regular Sudoku puzzles arent diagonal-rule Sudokus and youll need to find specific test cases for them.
You can solve other number puzzles (like Numbrix) with this technique by dropping in the appropriate validator. The rest of the code is unchanged.
The standard solver is worth full credit; a diagonal-rule solver gets you an additional 10 points. For yet another ten points there is the 16x16 Hexadoku, with sixteen 4x4 regions and entries in hexadecimal (0-9 and A-F), and even the base-36 puzzle using 0-9 and A-Z.
Note: if you are thinking ahead you can write an entirely generic Sudoku solver that will handle 4x4,9x9,16x16,25x25, and 36x36 puzzles (using 0-9 and A-Z gets you to base 36). The limitations are that you run out of symbols to represent the values if you go beyond base 36, and the algorithm is exponential so the solve times on larger puzzles can become...large.
Throw in a Numbrix solver for yet another 10 points. You can do Magic Squares as well, and pick up even more points.
The input file :
8--------
--36-----
-7--9-2--
-5---7---
----457--
---1---3-
--1----68
--85---1-
-9----4--

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions