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:
@@ -67,6 +67,9 @@ void Problem31::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "There are " << permutations << " ways to make 2 pounds with the given denominations of coins";
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -77,19 +80,6 @@ void Problem31::reset(){
|
||||
permutations = 0;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem31::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << "There are " << permutations << " ways to make 2 pounds with the given denominations of coins";
|
||||
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the number of correct permutations of the coins
|
||||
int Problem31::getPermutations() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user