{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw4 - #include#include#include#include#include#include...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <string> #include <cstring> #include <queue> #include <cstdlib> #include <climits> # using namespace std; u class Sudoku { public: Sudoku(){generate();} ~Sudoku(){}; ~ bool isValueValid(int row, int col, int value) { int startCol, startRow; for(int i = 0; i < 4; i++) if(matrix[i][col] == value) return false; //check for same value in column for(int i = 0; i < 4; i++) if(matrix[row][i] == value) return false; //check for same value in row startCol = col - col%2; startRow = row - row%2; for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) if(matrix[startRow + i][startCol + j] == value) return false; //check inside the minigrid return true; } string possibleValues(int row, int col) //returns the possible values for a cell { string posVal = "1234"; int startCol, startRow; char buffer[33]; string::size_type pos; for(int i = 0; i < 4; i++) //check within a column for unassigned values if(matrix[i][col] != 0) { _itoa_s(matrix[i][col], buffer, 33, 10); if((pos = posVal.find(buffer, 0)) < 4) posVal.erase(pos, 1); } for(int i = 0; i < 4; i++) //check within a row for unassigned values if(matrix[row][i] != 0) { _itoa_s(matrix[row][i], buffer, 33, 10); if((pos = posVal.find(buffer, 0)) < 4)
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern