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

@@ -66,14 +66,6 @@ std::vector<int> Problem18::list[NUM_ROWS] =
{04, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 04, 23}};
Problem18::Problem18() : Problem("Find the maximum total from the top to the bottom of the pyramid."), actualTotal(0){
//The method that I am using looks for the smallest numbers, so I need to invert the numbers in this list
invert();
//Now l[i][j] == 100 - l[i][j];
//Add the top point because that is already the only path
foundPoints.emplace_back(0, 0, list[0][0], false);
//Add the second row as possible points
possiblePoints.emplace_back(0, 1, (list[0][0] + list[1][0]), true);
possiblePoints.emplace_back(1, 1, (list[0][0] + list[1][1]), false);
}
void Problem18::invert(){
@@ -93,6 +85,15 @@ void Problem18::solve(){
//Start the timer
timer.start();
//The method that I am using looks for the smallest numbers, so I need to invert the numbers in this list
invert();
//Now l[i][j] == 100 - l[i][j];
//Add the top point because that is already the only path
foundPoints.emplace_back(0, 0, list[0][0], false);
//Add the second row as possible points
possiblePoints.emplace_back(0, 1, (list[0][0] + list[1][0]), true);
possiblePoints.emplace_back(1, 1, (list[0][0] + list[1][1]), false);
bool foundBottom = false; //Used when you find a point at the bottom
//Loop until you find the bottom
@@ -224,3 +225,10 @@ int Problem18::getTotal() const{
}
return actualTotal;
}
void Problem18::reset(){
Problem::reset();
foundPoints.clear();
possiblePoints.clear();
actualTotal = 0;
}