Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would a flowchart and/or pseudocode look for a function to check valid numbers, and a function to read the board look for a basic

How would a flowchart and/or pseudocode look for a function to check valid numbers, and a function to read the board look for a basic Sudoku program? Here is an example board from a text file:

 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

And these are the rules

Sudoku is a numbers game played on a 9x9 grid. The object of the game is to fill in the 9x9 grid while honoring certain constraints. The constraints are the following:

  • There is no more than one instance of a given number on a given row.
  • There is no more than one instance of a given number on a given column.
  • There is no more than one instance of a given number on an inside square (the 3x3 squares embedded in the 9x9 grid).
  • Every square can consist of a single digit between 1 and 9 exclusively, or can be blank.

The game is finished when every square in the 9x9 grid is filled.

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.

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions