generated from Trianta/cpp-unity-template
Final preparations for project
This commit is contained in:
parent
b7217dc877
commit
670027c119
@ -19,29 +19,72 @@ void Sudoku::FillBoard(std::string filePath) {
|
||||
sudokuFile >> line;
|
||||
std::cout << line << std::endl;
|
||||
}
|
||||
// TODO: Finish inputting sudoku file
|
||||
// Really just needs to be split by digit then stored
|
||||
|
||||
}
|
||||
|
||||
// TODO: Implement solving algorithm
|
||||
void Sudoku::Solve(void) {
|
||||
|
||||
}
|
||||
|
||||
// TODO: Add checking for full board completion
|
||||
bool Sudoku::IsBoardSolved(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Add printing of board for visuals
|
||||
// Maybe also print during solve?
|
||||
void Sudoku::Print(void) {
|
||||
|
||||
}
|
||||
|
||||
// TODO: Add checking for row completion
|
||||
bool Sudoku::IsRowComplete(int row) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Add checking for column completion
|
||||
bool Sudoku::IsColumnComplete(int column) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// WARNING: This function and one below could be swapped, untested
|
||||
std::vector<int> Sudoku::GetUnusedInRow(int row) {
|
||||
|
||||
std::vector<int> leftOver{0,1,2,3,4,5,6,7,8,9};
|
||||
int number;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
number = board[i][row];
|
||||
if (leftOver[number] == number) {
|
||||
leftOver[number] = 0;
|
||||
}
|
||||
if (leftOver[number] == 0) { // Two of same number was placed
|
||||
leftOver[number] = -1;
|
||||
}
|
||||
}
|
||||
for (auto it = leftOver.begin(); it != leftOver.end();) {
|
||||
if (*it == 0) { it = leftOver.erase(it); }
|
||||
else { ++it; }
|
||||
}
|
||||
return leftOver;
|
||||
}
|
||||
|
||||
std::vector<int> Sudoku::GetUnusedInColumn(int column) {
|
||||
|
||||
std::vector<int> leftOver{0,1,2,3,4,5,6,7,8,9};
|
||||
int number;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
number = board[column][i];
|
||||
if (leftOver[number] == number) {
|
||||
leftOver[number] = 0;
|
||||
}
|
||||
if (leftOver[number] == 0) { // Two of same number was placed
|
||||
leftOver[number] = -1;
|
||||
}
|
||||
}
|
||||
for (auto it = leftOver.begin(); it != leftOver.end();) {
|
||||
if (*it == 0) { it = leftOver.erase(it); }
|
||||
else { ++it; }
|
||||
}
|
||||
return leftOver;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ public:
|
||||
void FillBoard(std::string filePath);
|
||||
void Solve(void);
|
||||
bool IsBoardSolved(void);
|
||||
void Print(void);
|
||||
private:
|
||||
bool IsRowComplete(int row);
|
||||
bool IsColumnComplete(int column);
|
||||
|
@ -1,5 +1,9 @@
|
||||
#include "sudoku.hpp"
|
||||
|
||||
// TODO:
|
||||
// Take in sudoku file from arguments
|
||||
// Run solve
|
||||
// Print solution
|
||||
int main(void) {
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user