mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated how results are retrieved
This commit is contained in:
@@ -275,6 +275,10 @@ void Problem13::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The sum of all " << nums.size() << " numbers is " << sum
|
||||
<< "\nThe first 10 digits of the sum of the numbers is " << sum.get_str().substr(0, 10);
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -287,19 +291,6 @@ void Problem13::reset(){
|
||||
reserveVectors();
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem13::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << "The sum of all " << nums.size() << " numbers is " << sum
|
||||
<< "\nThe first 10 digits of the sum of the numbers is " << sum.get_str().substr(0, 10);
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the list 50-digit numbers
|
||||
std::vector<mpz_class> Problem13::getNumbers() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user