mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Changed exception to Unsolved to fit with naming convention
This commit is contained in:
@@ -33,7 +33,7 @@ protected:
|
|||||||
const std::string description; //Holds the description of the problem
|
const std::string description; //Holds the description of the problem
|
||||||
mee::Stopwatch timer; //Used to determine your algorithm's run time
|
mee::Stopwatch timer; //Used to determine your algorithm's run time
|
||||||
bool solved; //Holds true after the problem has been solved
|
bool solved; //Holds true after the problem has been solved
|
||||||
class unsolved{}; //An exception class thrown if you try to access something before it has been solved
|
class Unsolved{}; //An exception class thrown if you try to access something before it has been solved
|
||||||
public:
|
public:
|
||||||
//Constructors
|
//Constructors
|
||||||
Problem() : solved(false){
|
Problem() : solved(false){
|
||||||
@@ -48,9 +48,17 @@ public:
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
virtual std::string getTime(){
|
virtual std::string getTime(){
|
||||||
|
//If the problem hasn't been solved throw an exception
|
||||||
|
if(!solved){
|
||||||
|
throw Unsolved();
|
||||||
|
}
|
||||||
return timer.getStr();
|
return timer.getStr();
|
||||||
}
|
}
|
||||||
virtual mee::Stopwatch getTimer(){
|
virtual mee::Stopwatch getTimer(){
|
||||||
|
//If the problem hasn't been solved throw an exception
|
||||||
|
if(!solved){
|
||||||
|
throw Unsolved();
|
||||||
|
}
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
//Reset the problem so it can be run again
|
//Reset the problem so it can be run again
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void Problem1::reset(){
|
|||||||
std::string Problem1::getString() const{
|
std::string Problem1::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
//Create a string with the results and return it
|
//Create a string with the results and return it
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -89,7 +89,7 @@ std::string Problem1::getString() const{
|
|||||||
uint64_t Problem1::getSum() const{
|
uint64_t Problem1::getSum() const{
|
||||||
//If the prblem hasn't been solved throw an exception
|
//If the prblem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return fullSum;
|
return fullSum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void Problem10::reset(){
|
|||||||
std::string Problem10::getString() const{
|
std::string Problem10::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The sum of all the primes less than " << GOAL_NUMBER + 1 << " is " << sum;
|
results << "The sum of all the primes less than " << GOAL_NUMBER + 1 << " is " << sum;
|
||||||
@@ -78,7 +78,7 @@ std::string Problem10::getString() const{
|
|||||||
uint64_t Problem10::getSum() const{
|
uint64_t Problem10::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ void Problem11::reset(){
|
|||||||
std::string Problem11::getString() const{
|
std::string Problem11::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The greatest product of 4 number in a line is " << mee::getProduct(greatestProduct)
|
results << "The greatest product of 4 number in a line is " << mee::getProduct(greatestProduct)
|
||||||
@@ -200,7 +200,7 @@ std::string Problem11::getString() const{
|
|||||||
std::vector<int> Problem11::getNumbers() const{
|
std::vector<int> Problem11::getNumbers() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return greatestProduct;
|
return greatestProduct;
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ std::vector<int> Problem11::getNumbers() const{
|
|||||||
int Problem11::getProduct() const{
|
int Problem11::getProduct() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return mee::getProduct(greatestProduct);
|
return mee::getProduct(greatestProduct);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void Problem12::reset(){
|
|||||||
std::string Problem12::getString() const{
|
std::string Problem12::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The triangular number " << sum << " is a sum of all numbers >= " << counter - 1 << " and has " << divisors.size() << " divisors";
|
results << "The triangular number " << sum << " is a sum of all numbers >= " << counter - 1 << " and has " << divisors.size() << " divisors";
|
||||||
@@ -93,7 +93,7 @@ std::string Problem12::getString() const{
|
|||||||
int64_t Problem12::getTriangularNumber() const{
|
int64_t Problem12::getTriangularNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ int64_t Problem12::getTriangularNumber() const{
|
|||||||
int64_t Problem12::getLastNumberAdded() const{
|
int64_t Problem12::getLastNumberAdded() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return counter - 1;
|
return counter - 1;
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ int64_t Problem12::getLastNumberAdded() const{
|
|||||||
std::vector<int64_t> Problem12::getDivisorsOfTriangularNumber() const{
|
std::vector<int64_t> Problem12::getDivisorsOfTriangularNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return divisors;
|
return divisors;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ std::vector<int64_t> Problem12::getDivisorsOfTriangularNumber() const{
|
|||||||
size_t Problem12::getNumberOfDivisors() const{
|
size_t Problem12::getNumberOfDivisors() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return divisors.size();
|
return divisors.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ void Problem13::reset(){
|
|||||||
std::string Problem13::getString() const{
|
std::string Problem13::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -304,7 +304,7 @@ std::string Problem13::getString() const{
|
|||||||
std::vector<mpz_class> Problem13::getNumbers() const{
|
std::vector<mpz_class> Problem13::getNumbers() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return nums;
|
return nums;
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ std::vector<mpz_class> Problem13::getNumbers() const{
|
|||||||
mpz_class Problem13::getSum() const{
|
mpz_class Problem13::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ void Problem14::reset(){
|
|||||||
std::string Problem14::getString() const{
|
std::string Problem14::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -109,7 +109,7 @@ std::string Problem14::getString() const{
|
|||||||
uint64_t Problem14::getLength() const{
|
uint64_t Problem14::getLength() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return maxLength;
|
return maxLength;
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ uint64_t Problem14::getLength() const{
|
|||||||
uint64_t Problem14::getStartingNumber() const{
|
uint64_t Problem14::getStartingNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return maxNum;
|
return maxNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void Problem15::reset(){
|
|||||||
std::string Problem15::getString() const{
|
std::string Problem15::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -104,7 +104,7 @@ std::string Problem15::getString() const{
|
|||||||
uint64_t Problem15::getNumberOfRoutes() const{
|
uint64_t Problem15::getNumberOfRoutes() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return numOfRoutes;
|
return numOfRoutes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void Problem16::reset(){
|
|||||||
std::string Problem16::getString() const{
|
std::string Problem16::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -94,7 +94,7 @@ std::string Problem16::getString() const{
|
|||||||
mpz_class Problem16::getNumber() const{
|
mpz_class Problem16::getNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ mpz_class Problem16::getNumber() const{
|
|||||||
int Problem16::getSum() const{
|
int Problem16::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sumOfElements;
|
return sumOfElements;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ void Problem17::reset(){
|
|||||||
std::string Problem17::getString() const{
|
std::string Problem17::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The number of letters is " << letterCount;
|
results << "The number of letters is " << letterCount;
|
||||||
@@ -220,7 +220,7 @@ std::string Problem17::getString() const{
|
|||||||
uint64_t Problem17::getLetterCount() const{
|
uint64_t Problem17::getLetterCount() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return letterCount;
|
return letterCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void Problem18::reset(){
|
|||||||
std::string Problem18::getString() const{
|
std::string Problem18::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -163,7 +163,7 @@ std::string Problem18::getString() const{
|
|||||||
std::string Problem18::getPyramid(){
|
std::string Problem18::getPyramid(){
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ std::string Problem18::getPyramid(){
|
|||||||
std::string Problem18::getTrail(){
|
std::string Problem18::getTrail(){
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -237,7 +237,7 @@ std::string Problem18::getTrail(){
|
|||||||
int Problem18::getTotal() const{
|
int Problem18::getTotal() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return actualTotal;
|
return actualTotal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ void Problem19::reset(){
|
|||||||
std::string Problem19::getString() const{
|
std::string Problem19::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "There are " << totalSundays << " Sundays that landed on the first of the months from " << START_YEAR << " to " << END_YEAR;
|
results << "There are " << totalSundays << " Sundays that landed on the first of the months from " << START_YEAR << " to " << END_YEAR;
|
||||||
@@ -196,7 +196,7 @@ std::string Problem19::getString() const{
|
|||||||
uint64_t Problem19::getTotalSundays() const{
|
uint64_t Problem19::getTotalSundays() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return totalSundays;
|
return totalSundays;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ void Problem2::reset(){
|
|||||||
std::string Problem2::getString() const{
|
std::string Problem2::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The sum of the even Fibonacci numbers less than 4,000,000 is " << fullSum;
|
results << "The sum of the even Fibonacci numbers less than 4,000,000 is " << fullSum;
|
||||||
@@ -86,7 +86,7 @@ std::string Problem2::getString() const{
|
|||||||
uint64_t Problem2::getSum() const{
|
uint64_t Problem2::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return fullSum;
|
return fullSum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ void Problem20::reset(){
|
|||||||
std::string Problem20::getString() const{
|
std::string Problem20::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
//Print the results
|
//Print the results
|
||||||
@@ -92,7 +92,7 @@ std::string Problem20::getString() const{
|
|||||||
mpz_class Problem20::getNumber() const{
|
mpz_class Problem20::getNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ mpz_class Problem20::getNumber() const{
|
|||||||
std::string Problem20::getNumberString() const{
|
std::string Problem20::getNumberString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return num.get_str();
|
return num.get_str();
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ std::string Problem20::getNumberString() const{
|
|||||||
uint64_t Problem20::getSum() const{
|
uint64_t Problem20::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void Problem21::reset(){
|
|||||||
std::string Problem21::getString() const{
|
std::string Problem21::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -119,7 +119,7 @@ std::string Problem21::getString() const{
|
|||||||
std::vector<uint64_t> Problem21::getAmicable() const{
|
std::vector<uint64_t> Problem21::getAmicable() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return amicable;
|
return amicable;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ std::vector<uint64_t> Problem21::getAmicable() const{
|
|||||||
uint64_t Problem21::getSum() const{
|
uint64_t Problem21::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return mee::getSum(amicable);
|
return mee::getSum(amicable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ void Problem22::reset(){
|
|||||||
std::string Problem22::getString() const{
|
std::string Problem22::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The answer to the question is " << mee::getSum(prod);
|
results << "The answer to the question is " << mee::getSum(prod);
|
||||||
@@ -472,7 +472,7 @@ std::string Problem22::getString() const{
|
|||||||
std::vector<std::string> Problem22::getNames() const{
|
std::vector<std::string> Problem22::getNames() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
@@ -481,7 +481,7 @@ std::vector<std::string> Problem22::getNames() const{
|
|||||||
uint64_t Problem22::getNameScoreSum() const{
|
uint64_t Problem22::getNameScoreSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return mee::getSum(prod);
|
return mee::getSum(prod);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ void Problem23::reset(){
|
|||||||
std::string Problem23::getString() const{
|
std::string Problem23::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The answer is " << sum;
|
results << "The answer is " << sum;
|
||||||
@@ -131,7 +131,7 @@ std::string Problem23::getString() const{
|
|||||||
uint64_t Problem23::getSum() const{
|
uint64_t Problem23::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ void Problem24::reset(){
|
|||||||
std::string Problem24::getString() const{
|
std::string Problem24::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
//Print the results
|
//Print the results
|
||||||
@@ -81,7 +81,7 @@ std::string Problem24::getString() const{
|
|||||||
std::vector<std::string> Problem24::getPermutationsList() const{
|
std::vector<std::string> Problem24::getPermutationsList() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return permutations;
|
return permutations;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ std::vector<std::string> Problem24::getPermutationsList() const{
|
|||||||
std::string Problem24::getPermutation() const{
|
std::string Problem24::getPermutation() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return permutations.at(NEEDED_PERM - 1);
|
return permutations.at(NEEDED_PERM - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void Problem25::reset(){
|
|||||||
std::string Problem25::getString() const{
|
std::string Problem25::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -89,7 +89,7 @@ std::string Problem25::getString() const{
|
|||||||
mpz_class Problem25::getNumber() const{
|
mpz_class Problem25::getNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ mpz_class Problem25::getNumber() const{
|
|||||||
std::string Problem25::getNumberString() const{
|
std::string Problem25::getNumberString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return number.get_str();
|
return number.get_str();
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ std::string Problem25::getNumberString() const{
|
|||||||
mpz_class Problem25::getIndex() const{
|
mpz_class Problem25::getIndex() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ mpz_class Problem25::getIndex() const{
|
|||||||
std::string Problem25::getIndexString() const{
|
std::string Problem25::getIndexString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return index.get_str();
|
return index.get_str();
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ std::string Problem25::getIndexString() const{
|
|||||||
uint64_t Problem25::getIndexInt() const{
|
uint64_t Problem25::getIndexInt() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return index.get_ui();
|
return index.get_ui();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ void Problem26::reset(){
|
|||||||
std::string Problem26::getString() const{
|
std::string Problem26::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -118,7 +118,7 @@ std::string Problem26::getString() const{
|
|||||||
unsigned int Problem26::getLongestCycle() const{
|
unsigned int Problem26::getLongestCycle() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return longestCycle;
|
return longestCycle;
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ unsigned int Problem26::getLongestCycle() const{
|
|||||||
unsigned int Problem26::getLongestNumber() const{
|
unsigned int Problem26::getLongestNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return longestNumber;
|
return longestNumber;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ void Problem27::reset(){
|
|||||||
std::string Problem27::getString() const{
|
std::string Problem27::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -100,7 +100,7 @@ std::string Problem27::getString() const{
|
|||||||
int64_t Problem27::getTopA() const{
|
int64_t Problem27::getTopA() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return topA;
|
return topA;
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ int64_t Problem27::getTopA() const{
|
|||||||
int64_t Problem27::getTopB() const{
|
int64_t Problem27::getTopB() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return topB;
|
return topB;
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ int64_t Problem27::getTopB() const{
|
|||||||
int64_t Problem27::getTopN() const{
|
int64_t Problem27::getTopN() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return topN;
|
return topN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ void Problem28::reset(){
|
|||||||
std::string Problem28::getString() const{
|
std::string Problem28::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -161,7 +161,7 @@ std::string Problem28::getString() const{
|
|||||||
std::vector<std::vector<int>> Problem28::getGrid() const{
|
std::vector<std::vector<int>> Problem28::getGrid() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ std::vector<std::vector<int>> Problem28::getGrid() const{
|
|||||||
uint64_t Problem28::getSum() const{
|
uint64_t Problem28::getSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sumOfDiagonals;
|
return sumOfDiagonals;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ void Problem29::reset(){
|
|||||||
std::string Problem29::getString() const{
|
std::string Problem29::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -100,7 +100,7 @@ std::string Problem29::getString() const{
|
|||||||
unsigned int Problem29::getBottomA() const{
|
unsigned int Problem29::getBottomA() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return BOTTOM_A;
|
return BOTTOM_A;
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ unsigned int Problem29::getBottomA() const{
|
|||||||
unsigned int Problem29::getTopA() const{
|
unsigned int Problem29::getTopA() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return TOP_A;
|
return TOP_A;
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ unsigned int Problem29::getTopA() const{
|
|||||||
unsigned int Problem29::getBottomB() const{
|
unsigned int Problem29::getBottomB() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return BOTTOM_B;
|
return BOTTOM_B;
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ unsigned int Problem29::getBottomB() const{
|
|||||||
unsigned int Problem29::getTopB() const{
|
unsigned int Problem29::getTopB() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return TOP_B;
|
return TOP_B;
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ unsigned int Problem29::getTopB() const{
|
|||||||
std::vector<mpz_class> Problem29::getUnique() const{
|
std::vector<mpz_class> Problem29::getUnique() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return unique;
|
return unique;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void Problem3::reset(){
|
|||||||
std::string Problem3::getString() const{
|
std::string Problem3::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The largest factor of the number " << GOAL_NUMBER << " is " << factors[factors.size() - 1];
|
results << "The largest factor of the number " << GOAL_NUMBER << " is " << factors[factors.size() - 1];
|
||||||
@@ -79,7 +79,7 @@ std::string Problem3::getString() const{
|
|||||||
std::vector<uint64_t> Problem3::getFactors() const{
|
std::vector<uint64_t> Problem3::getFactors() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return factors;
|
return factors;
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ std::vector<uint64_t> Problem3::getFactors() const{
|
|||||||
uint64_t Problem3::getLargestFactor() const{
|
uint64_t Problem3::getLargestFactor() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
return *factors.end();
|
return *factors.end();
|
||||||
@@ -98,7 +98,7 @@ uint64_t Problem3::getLargestFactor() const{
|
|||||||
uint64_t Problem3::getGoalNumber() const{
|
uint64_t Problem3::getGoalNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return GOAL_NUMBER;
|
return GOAL_NUMBER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ void Problem30::reset(){
|
|||||||
std::string Problem30::getString() const{
|
std::string Problem30::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -110,7 +110,7 @@ std::string Problem30::getString() const{
|
|||||||
uint64_t Problem30::getTopNum() const{
|
uint64_t Problem30::getTopNum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
return TOP_NUM;
|
return TOP_NUM;
|
||||||
@@ -120,7 +120,7 @@ uint64_t Problem30::getTopNum() const{
|
|||||||
std::vector<uint64_t> Problem30::getListOfSumOfFifths() const{
|
std::vector<uint64_t> Problem30::getListOfSumOfFifths() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sumOfFifthNumbers;
|
return sumOfFifthNumbers;
|
||||||
@@ -130,7 +130,7 @@ std::vector<uint64_t> Problem30::getListOfSumOfFifths() const{
|
|||||||
uint64_t Problem30::getSumOfList() const{
|
uint64_t Problem30::getSumOfList() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void Problem31::reset(){
|
|||||||
std::string Problem31::getString() const{
|
std::string Problem31::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -94,7 +94,7 @@ std::string Problem31::getString() const{
|
|||||||
int Problem31::getPermutations() const{
|
int Problem31::getPermutations() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return permutations;
|
return permutations;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ void Problem4::reset(){
|
|||||||
std::string Problem4::getString() const{
|
std::string Problem4::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
//Print the results
|
//Print the results
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -101,7 +101,7 @@ std::string Problem4::getString() const{
|
|||||||
std::vector<uint64_t> Problem4::getPalindromes() const{
|
std::vector<uint64_t> Problem4::getPalindromes() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return palindromes;
|
return palindromes;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ std::vector<uint64_t> Problem4::getPalindromes() const{
|
|||||||
uint64_t Problem4::getLargestPalindrome() const{
|
uint64_t Problem4::getLargestPalindrome() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return *(palindromes.end() - 1);
|
return *(palindromes.end() - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void Problem5::reset(){
|
|||||||
std::string Problem5::getString() const{
|
std::string Problem5::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The smallest positive number evenly divisible by all numbers 1-20 is " << smallestNum;
|
results << "The smallest positive number evenly divisible by all numbers 1-20 is " << smallestNum;
|
||||||
@@ -97,7 +97,7 @@ std::string Problem5::getString() const{
|
|||||||
int Problem5::getNumber() const{
|
int Problem5::getNumber() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return smallestNum;
|
return smallestNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ void Problem6::reset(){
|
|||||||
std::string Problem6::getString() const{
|
std::string Problem6::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The difference between the sum of the squares and the square of the sum of all numbers from 1-100 is " << abs(sumOfSquares - squareOfSum);
|
results << "The difference between the sum of the squares and the square of the sum of all numbers from 1-100 is " << abs(sumOfSquares - squareOfSum);
|
||||||
@@ -83,7 +83,7 @@ std::string Problem6::getString() const{
|
|||||||
uint64_t Problem6::getSumOfSquares() const{
|
uint64_t Problem6::getSumOfSquares() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return sumOfSquares;
|
return sumOfSquares;
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ uint64_t Problem6::getSumOfSquares() const{
|
|||||||
uint64_t Problem6::getSquareOfSum() const{
|
uint64_t Problem6::getSquareOfSum() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return squareOfSum;
|
return squareOfSum;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ uint64_t Problem6::getSquareOfSum() const{
|
|||||||
uint64_t Problem6::getDifference() const{
|
uint64_t Problem6::getDifference() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return abs(sumOfSquares - squareOfSum);
|
return abs(sumOfSquares - squareOfSum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ void Problem67::reset(){
|
|||||||
std::string Problem67::getString() const{
|
std::string Problem67::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -339,7 +339,7 @@ std::string Problem67::getString() const{
|
|||||||
std::string Problem67::getPyramid() const{
|
std::string Problem67::getPyramid() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ std::string Problem67::getPyramid() const{
|
|||||||
std::string Problem67::getTrail(){
|
std::string Problem67::getTrail(){
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
@@ -413,7 +413,7 @@ std::string Problem67::getTrail(){
|
|||||||
int Problem67::getTotal() const{
|
int Problem67::getTotal() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return actualTotal;
|
return actualTotal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void Problem7::reset(){
|
|||||||
std::string Problem7::getString() const{
|
std::string Problem7::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The " << NUMBER_OF_PRIMES << "th prime number is " << primes.at(primes.size() - 1);
|
results << "The " << NUMBER_OF_PRIMES << "th prime number is " << primes.at(primes.size() - 1);
|
||||||
@@ -78,7 +78,7 @@ std::string Problem7::getString() const{
|
|||||||
uint64_t Problem7::getPrime() const{
|
uint64_t Problem7::getPrime() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return *primes.end();
|
return *primes.end();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ void Problem8::reset(){
|
|||||||
std::string Problem8::getString() const{
|
std::string Problem8::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
results << "The greatest product is " << maxProduct
|
results << "The greatest product is " << maxProduct
|
||||||
@@ -111,7 +111,7 @@ std::string Problem8::getString() const{
|
|||||||
std::string Problem8::getLargestNums() const{
|
std::string Problem8::getLargestNums() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return maxNums;
|
return maxNums;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ std::string Problem8::getLargestNums() const{
|
|||||||
uint64_t Problem8::getLargestProduct() const{
|
uint64_t Problem8::getLargestProduct() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return maxProduct;
|
return maxProduct;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ void Problem9::reset(){
|
|||||||
std::string Problem9::getString() const{
|
std::string Problem9::getString() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream results;
|
std::stringstream results;
|
||||||
if(found){
|
if(found){
|
||||||
@@ -101,7 +101,7 @@ std::string Problem9::getString() const{
|
|||||||
int Problem9::getSideA() const{
|
int Problem9::getSideA() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ int Problem9::getSideA() const{
|
|||||||
int Problem9::getSideB() const{
|
int Problem9::getSideB() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ int Problem9::getSideB() const{
|
|||||||
int Problem9::getSideC() const{
|
int Problem9::getSideC() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return (int)c;
|
return (int)c;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ int Problem9::getSideC() const{
|
|||||||
int Problem9::getProduct() const{
|
int Problem9::getProduct() const{
|
||||||
//If the problem hasn't been solved throw an exception
|
//If the problem hasn't been solved throw an exception
|
||||||
if(!solved){
|
if(!solved){
|
||||||
throw unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
return a * b * (int)c;
|
return a * b * (int)c;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user