Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; bool sudokuChecker(int board[][9]) { // Your code goes here. Return true if each row and column in board sum to 45.

image text in transcribed

#include

using namespace std;

bool sudokuChecker(int board[][9])

{

// Your code goes here. Return true if each row and column in board sum to 45.

// Return false otherwise.

}

int main()

{

int sudoku_board[9][9];

for(int i = 0; i

for(int j = 0; j

cin >> sudoku_board[i][j];

if (sudokuChecker(sudoku_board)) cout

else cout

return 0;

}

Sudoku is a game in which the numbers 1-9 are placed on a 9x9 game board, such that each row, column, and 3x3 sque contains each of the numbers 1-9 with no duplicates. In this assignment you are going to write a function that takes an input a 2-dimenstional 9x9 array of integers. Your function should check to see that digits in each row and column add up to exactly 45. If the sum of each row and each column is 45, your function should return true, otherwise it should return false. Note, you should not check 3x3 squares. Also, note that a valid sudoku game will have the property that each row and column sum to 45, this is not sufficient to be a legal game. For example a row that contains 55555 5 5 5 5 sums to 45, but would not be legal in the game. However, for this exercise, just check the sums as indicated above. A main function is provided to check your code Your function will be called sudokuChecker, and the header of the function is provided for you. The parameter board is the 9x9 array of digits that you must check. Your function should not contain any cout or cin statements. Input and output are handled in the provided main0 function. Sample run 1 1 2 3456789 1 2 3456789 1 2 3 456789 1 2 3 456789 1 2 3 456789 1 2 3456789 1 2 3456789 1 2 3 4 56 789 1 2 3 4 56 789 Board is invalid Sample run 2: 1 2 3 4 56 789 2 3 4 567891 3 45 678 912 4 567 891 2 3 5678912 3 4 6 7 8 912345 7891 23456 891 2 345 67 91 2 345678 Board could be valid

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

ISBN: B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions