Problem 22 now loads names through a text file

This commit is contained in:
2021-07-03 03:06:35 -04:00
parent 9660fe9287
commit 43bdda8cd1
3 changed files with 5184 additions and 375 deletions

View File

@@ -33,14 +33,14 @@
class Problem22 : public Problem{
private:
//Variables
//Static variables
static std::vector<std::string> names; //Holds the names that will be scored
//Instance variables
std::vector<std::string> names; //Holds the names that will be scored
std::vector<uint64_t> sums; //Holds the score based on the sum of the characters in the name
std::vector<uint64_t> prod; //Holds the score based on the sum of the characters and the location in alphabetical order
uint64_t sum; //Holds the sum of the scores
//Functions
void getNames(); //Take the names from the file and insert them into the vector
void reserveVectors(); //Reserve the size of the vector to speed up insertion
public:
//Constructor
@@ -57,7 +57,7 @@ public:
/* Results:
The answer to the question is 871198282
It took an average of 436.559 microseconds to run this problem over 100 iterations
It took an average of 569.874 microseconds to run this problem over 100 iterations
*/