Question: Program the game Sudoku (https://en.wikipedia.org/wiki/Sudoku). You must therefore complete the program for this game. A program part is given in two files: D4Q3.py and gameSudoku.py

Program the game Sudoku (https://en.wikipedia.org/wiki/Sudoku). You must therefore complete

the program for this game. A program part is given in two files: D4Q3.py and

gameSudoku.py (which you must complete). Do not modify the prototypes of the functions. You

must implement the functions for this game. An example of game execution is given at the end of this

document.

The main program controls the game (it is already given).

At the beginning a menu of 3 choices is displayed to the user. Then he asks the input user his

choice. It is assumed that the user will enter exactly the right choice (a choice between 1 and 3) so the

validity of the choice is not verified.

- Choice 1: it resets the Sudoku grid by the matrix given in the main program

(in the D4Q3.py file). Afterwards, the game starts by following the same steps as the choice

2.

- Choice 2: the game begins. It displays the grid on the screen and then ask the user to enter

the box to play (he must enter the number of the line, the column and the number he wants to add).

If the box to play is correct (a valid box), then you must display the message Bravo !!. Otherwise, the

Failed message will be displayed. If the box is already filled or if the Sudoku grid is full,

displays the appropriate message to the user.

- The choice 3: The game stops. The message Goodbye! is posted.

In order to control the game well, it is necessary to implement the following functions:

- ViewGrid (): Displays a Sudoku grid in 9x9 matrix format.

- VerifierLigne (): Check whether the number to be added already exists on the line.

- VerifierCol (): Check whether the number to add already exists on the column.

- VerifierSousGrille (): to check if the number to add already exists on the sub-grid where

the addition will be done.

- VerifierCase (): check if a box is valid ie the number to add does not exist nor on the

line, neither on the column, nor on the sub-grid.

- VerifierGagner (): check if the grid is complete ie there is no zero box in the grid.

In this case, the function returns True.

- Play (): add a box in the Sudoku grid only if the box is valid.

Note that:

1) After each menu selection, the grid is redisplayed after modification (if there is one) and the menu with

options and asks the user to re-enter a choice until the user

chose option 3 or the grid is completed.

2) The box to be added is requested to the user with input (). We do not check the validity of these

entered (it is assumed that the user will always enter a number between 1 and 9 and a line number

and column number between 0 and 8).

3) The functions verifierLine (), verifierCol (), verifierSousGrille () return True if the number

does not exist on the row or column or subgrid.

example:

Menu: 1- Start a new game..

2- Continue the game.

3- Quit the game.

please enter your choice (1, 2 ou 3): 1

5 3 8 6 9 1 0 4 7

7 4 6 5 3 2 8 1 9

1 9 2 7 8 4 3 5 6

8 7 1 2 6 3 4 9 5

3 2 9 4 5 7 1 6 8

4 6 5 9 1 8 7 2 3

6 1 4 3 7 9 5 8 2

9 8 3 1 2 5 6 7 4

2 5 0 8 4 6 9 3 1

Enter your choice of line box: 0

Enter your choice of box col: 6

Enter your choice of box num: 2

Congratulations!!

5 3 8 6 9 1 2 4 7

7 4 6 5 3 2 8 1 9

1 9 2 7 8 4 3 5 6

8 7 1 2 6 3 4 9 5

3 2 9 4 5 7 1 6 8

4 6 5 9 1 8 7 2 3

6 1 4 3 7 9 5 8 2

9 8 3 1 2 5 6 7 4

2 5 0 8 4 6 9 3 1

Menu: 1- Start a new game.

2- Continue the game.

3- Quit the game.

Please Enter your choice(1, 2 ou 3): 2

5 3 8 6 9 1 2 4 7

7 4 6 5 3 2 8 1 9

1 9 2 7 8 4 3 5 6

8 7 1 2 6 3 4 9 5

3 2 9 4 5 7 1 6 8

4 6 5 9 1 8 7 2 3

6 1 4 3 7 9 5 8 2

9 8 3 1 2 5 6 7 4

2 5 0 8 4 6 9 3 1

Enter your choice of line box: 1

Enter your choice of box col: 2

Enter your choice of box num: 7

Box already filled !!

Menu: 1- Start a new game.

2- Continue the game..

3- Quit the game.

Please Enter your choice(1, 2 ou 3): 2

5 3 8 6 9 1 2 4 7

7 4 6 5 3 2 8 1 9

1 9 2 7 8 4 3 5 6

8 7 1 2 6 3 4 9 5

3 2 9 4 5 7 1 6 8

4 6 5 9 1 8 7 2 3

6 1 4 3 7 9 5 8 2

9 8 3 1 2 5 6 7 4

2 5 0 8 4 6 9 3 1

Enter your choice of line box: : 8

Enter your choice of box col: 2

Enter your choice of box num: 5

Failed!!

Menu: 1- Start a new game.

2- Continue the game.

3- Quit the game.

Please Enter your choice(1, 2 ou 3): 2

5 3 8 6 9 1 2 4 7

7 4 6 5 3 2 8 1 9

1 9 2 7 8 4 3 5 6

8 7 1 2 6 3 4 9 5

3 2 9 4 5 7 1 6 8

4 6 5 9 1 8 7 2 3

6 1 4 3 7 9 5 8 2

9 8 3 1 2 5 6 7 4

2 5 0 8 4 6 9 3 1

Enter your choice of line box: : 8

Enter your choice of box col:: 2

Enter your choice of box num:: 7

Congratulations!!

5 3 8 6 9 1 2 4 7

7 4 6 5 3 2 8 1 9

1 9 2 7 8 4 3 5 6

8 7 1 2 6 3 4 9 5

3 2 9 4 5 7 1 6 8

4 6 5 9 1 8 7 2 3

6 1 4 3 7 9 5 8 2

9 8 3 1 2 5 6 7 4

2 5 7 8 4 6 9 3 1

Congratulations!! You have won

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 Programming Questions!