mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 09:33:57 -05:00
Problem 22 now loads names through a text file
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user