Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives: Interact with a 2D array Utilize smart pointers to directly manipulate memory. Problem: Sudoku continues to be one of the most popular puzzles. Its

Objectives: Interact with a 2D array Utilize smart pointers to directly manipulate memory. Problem: Sudoku continues to be one of the most popular puzzles. Its simple design and challenging logic has made it a hit amongst those that are not quite as good at memorizing words and definitions. The compact design of the puzzle also makes it easy to validate a correct solution. Your task is to create a program to validate a correct Sudoku solution.

Details:

Sudoku puzzles are created in a 9x9 grid.

Each row must contain each number 1-9

. Each column must contain each number 1-9.

Each row and column is divided in thirds to create 9 3x3 grids

. o Each 3x3 grid must contain each number 1-9.

If any of the above contain a duplicate number, the solution is invalid.

Each puzzle may contain numbers and blank spaces

o A blank space will be displayed as a space character

The puzzles may not be solved o If the puzzle has spaces, the puzzle is not solved

o Determine if the numbers given are part of a possible solution

All array manipulation must be done using smart pointers. (-10 points)

All pointer movement must be done using pointer arithmetic (-10 points)

Any arrays used must be created dynamically.

o Dynamic 2D arrays can be created with double pointers or created as a long single dimension array

Comment your code generously. Refer to the grading rubric for more details.

Use as few variables as possible. Dont waste memory holding a calculation just so you can print it out one time

. User Interface: There will be no user interface for this program. All I/O will be file based.

Input:

All input will be in a file named puzzles.txt

The file may contain multiple puzzles Each puzzle will be numbered

The puzzles will be formatted as follows: o Puzzle number on a line by itself integer value o Sudoku puzzle 9 lines of numbers and spaces

A space is not a delimiter

A space just means there is no value in that block of the puzzle

All numbers will be single digits (1-9) o Newline

There may or may not be a newline after the last puzzle in the file

Output:

All output will be written to a file named solutions.txt.

Create a table with three columns o Puzzle number o Valid/invalid/solved o Reason puzzle is invalid (if applicable)

Example: column 2 has two 5s

Example: Upper middle grid has two 7s

A puzzle is solved if it is valid and there are no spaces in the puzzle

Each puzzle validation will be listed on a separate line

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 Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions