Updated comments and made sure style was consistent

This commit is contained in:
2020-07-10 13:36:16 -04:00
parent 7257a118d4
commit c72754dcf8
65 changed files with 1160 additions and 747 deletions

View File

@@ -1,7 +1,7 @@
//ProjectEuler/C++/Headers/Problem13.hpp
//ProjectEuler/ProjectEulerCPP/Headers/Problem13.hpp
//Matthew Ellison
// Created: 09-29-18
//Modified: 07-14-19
//Modified: 07-09-20
//Work out the first ten digits of the sum of the following one-hundred 50-digit numbers
/*
37107287533902102798797998220837590246510135740250
@@ -110,7 +110,7 @@
//You can find more information about them at https://gmplib.org/
//When compiling this file you need to have the gmp library installed as well as linking the libraries to your executable using the -lgmpxx and -lgmp flags
/*
Copyright (C) 2019 Matthew Ellison
Copyright (C) 2020 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -139,27 +139,31 @@
class Problem13 : public Problem{
private:
//A vector to hold all of the numbers
std::vector<mpz_class> nums;
mpz_class sum;
void setNums();
void reserveVectors();
//Variables
//Instance variables
std::vector<mpz_class> nums; //A vector to hold all of the numbers
mpz_class sum; //The sum of all the numbers
//Functions
void setNums(); //A function to set the nums vector
void reserveVectors(); //Reserve the size of the vector to speed up insertion
public:
//Constructor
Problem13();
virtual void solve();
virtual std::string getString() const;
virtual void reset();
//Returns the list 50-digit numbers
std::vector<mpz_class> getNumbers() const;
//Returns the sum of the 50-digit numbers
mpz_class getSum() const;
//Operational functions
virtual void solve(); //Solve the problem
virtual void reset(); //Reset the problem so it can be run again
//Gets
virtual std::string getString() const; //Return a string with the solution to the problem
std::vector<mpz_class> getNumbers() const; //Returns the list 50-digit numbers
mpz_class getSum() const; //Returns the sum of the 50-digit numbers
};
/* Results:
The sum of all 100 numbers is 5537376230390876637302048746832985971773659831892672
The first 10 digits of the sum of the numbers is 5537376230
It took 0.000 nanoseconds to solve this problem.
It took an average of 13.270 microseconds to run this problem over 100 iterations
*/
#endif //PROBLEM13_HPP