Added a benchmark tool

This commit is contained in:
2020-07-08 20:38:37 -04:00
parent a7d960c3b1
commit 766af92f1a
68 changed files with 546 additions and 134 deletions

View File

@@ -30,6 +30,10 @@
Problem28::Problem28() : Problem("What is the sum of the number on the diagonals in a 1001 x 1001 spiral formed by starting with the number 1 and moving to the right in a clockwise direction?"){
setupGrid();
sumOfDiagonals = 0;
}
void Problem28::setupGrid(){
//Set the size of the grid to 1001 x 1001
for(int cnt = 0;cnt < 1001;++cnt){
grid.emplace_back();
@@ -37,11 +41,10 @@ Problem28::Problem28() : Problem("What is the sum of the number on the diagonals
grid.at(cnt).push_back(0);
}
}
sumOfDiagonals = 0;
}
//Sets up the grid
void Problem28::setupGrid(){
void Problem28::createGrid(){
bool finalLocation = false; //A flag to indicate if the final location to be filled has been reached
//Set the number that is going to be put at each location
int currentNum = 1;
@@ -117,7 +120,7 @@ void Problem28::solve(){
//Setup the grid
setupGrid();
createGrid();
//Find the sum of the diagonals in the grid
findSum();
@@ -158,3 +161,10 @@ uint64_t Problem28::getSum() const{
}
return sumOfDiagonals;
}
void Problem28::reset(){
Problem::reset();
sumOfDiagonals = 0;
grid.clear();
setupGrid();
}