Question: Write in python The program will prompt the user for the filename of the game he or she is currently working on and display the

Write in python

The program will prompt the user for the filename of the game he or she is currently working on and display the board on the screen. The user will then be allowed to interact with the game by selecting which square he or she wishes to change. While the program will not solve the game for the user, it will ensure that the user has not selected an invalid number. If the user types 'S' in the prompt, then the program will show the user the possible valid numbers for a given square. When the user is finished, then the program will save the board to a given filename and exit.

Consider a game saved as myGame.txt:

{ "board": [ [ 7, 2, 3, 0, 0, 0, 1, 5, 9 ], [ 6, 0, 0, 3, 0, 2, 0, 0, 8 ], [ 8, 0, 0, 0, 1, 0, 0, 0, 2 ], [ 0, 7, 0, 6, 5, 4, 0, 2, 0 ], [ 0, 0, 4, 2, 0, 7, 3, 0, 0 ], [ 0, 5, 0, 9, 3, 1, 0, 4, 0 ], [ 5, 0, 0, 0, 7, 0, 0, 0, 3 ], [ 4, 0, 0, 1, 0, 3, 0, 0, 6 ], [ 9, 3, 2, 0, 0, 0, 7, 1, 4 ] ] }

Note that '0' corresponds to an unknown value. The following is an example run of the program.

An example of user input is underlined.

Where is your board located? myGame.txt

With the filename specified, the program will display the board as it currently stands:

 A B C D E F G H I 1 7 2 3| |1 5 9 2 6 |3 2| 8 3 8 | 1 | 2 -----+-----+----- 4 7 |6 5 4| 2 5 4|2 7|3 6 5 |9 3 1| 4 -----+-----+----- 7 5 | 7 | 3 8 4 |1 3| 6 9 9 3 2| |7 1 4 

Here, the user will be prompted for a square to edit. Please note that you will need a newline, a carat ('>'), and a space before the prompt.

> E5

If the user types "quit" then the program will prompt the user to save the file and quit. Otherwise, the program will assume the user entered coordinates. If the coordinates are invalid or the square is filled, then an error message will be displayed:

ERROR: Square zz is invalid
ERROR: Square A1 is filled

With a valid coordinate, then the program next prompts the user for the value:

What is the value at 'E5': 9

If the user types a value that is outside the accepted range (1 value 9) or does not follow the rules of Sudoku, then a message appears and the program returns to the main prompt:

ERROR: The value 9 is invalid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!