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
|
||||
mee::Stopwatch timer; //Used to determine your algorithm's run time
|
||||
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:
|
||||
//Constructors
|
||||
Problem() : solved(false){
|
||||
@@ -48,9 +48,17 @@ public:
|
||||
return description;
|
||||
}
|
||||
virtual std::string getTime(){
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
return timer.getStr();
|
||||
}
|
||||
virtual mee::Stopwatch getTimer(){
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
return timer;
|
||||
}
|
||||
//Reset the problem so it can be run again
|
||||
|
||||
@@ -78,7 +78,7 @@ void Problem1::reset(){
|
||||
std::string Problem1::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
//Create a string with the results and return it
|
||||
std::stringstream results;
|
||||
@@ -89,7 +89,7 @@ std::string Problem1::getString() const{
|
||||
uint64_t Problem1::getSum() const{
|
||||
//If the prblem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return fullSum;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void Problem10::reset(){
|
||||
std::string Problem10::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ void Problem11::reset(){
|
||||
std::string Problem11::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return greatestProduct;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ std::vector<int> Problem11::getNumbers() const{
|
||||
int Problem11::getProduct() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return mee::getProduct(greatestProduct);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ void Problem12::reset(){
|
||||
std::string Problem12::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ int64_t Problem12::getTriangularNumber() const{
|
||||
int64_t Problem12::getLastNumberAdded() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return counter - 1;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ int64_t Problem12::getLastNumberAdded() const{
|
||||
std::vector<int64_t> Problem12::getDivisorsOfTriangularNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return divisors;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ std::vector<int64_t> Problem12::getDivisorsOfTriangularNumber() const{
|
||||
size_t Problem12::getNumberOfDivisors() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return divisors.size();
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ void Problem13::reset(){
|
||||
std::string Problem13::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -304,7 +304,7 @@ std::string Problem13::getString() const{
|
||||
std::vector<mpz_class> Problem13::getNumbers() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return nums;
|
||||
}
|
||||
@@ -313,7 +313,7 @@ std::vector<mpz_class> Problem13::getNumbers() const{
|
||||
mpz_class Problem13::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ void Problem14::reset(){
|
||||
std::string Problem14::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -109,7 +109,7 @@ std::string Problem14::getString() const{
|
||||
uint64_t Problem14::getLength() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return maxLength;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ uint64_t Problem14::getLength() const{
|
||||
uint64_t Problem14::getStartingNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return maxNum;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ void Problem15::reset(){
|
||||
std::string Problem15::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -104,7 +104,7 @@ std::string Problem15::getString() const{
|
||||
uint64_t Problem15::getNumberOfRoutes() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return numOfRoutes;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void Problem16::reset(){
|
||||
std::string Problem16::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -94,7 +94,7 @@ std::string Problem16::getString() const{
|
||||
mpz_class Problem16::getNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return num;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ mpz_class Problem16::getNumber() const{
|
||||
int Problem16::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sumOfElements;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ void Problem17::reset(){
|
||||
std::string Problem17::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The number of letters is " << letterCount;
|
||||
@@ -220,7 +220,7 @@ std::string Problem17::getString() const{
|
||||
uint64_t Problem17::getLetterCount() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return letterCount;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ void Problem18::reset(){
|
||||
std::string Problem18::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -163,7 +163,7 @@ std::string Problem18::getString() const{
|
||||
std::string Problem18::getPyramid(){
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
|
||||
@@ -180,7 +180,7 @@ std::string Problem18::getPyramid(){
|
||||
std::string Problem18::getTrail(){
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -237,7 +237,7 @@ std::string Problem18::getTrail(){
|
||||
int Problem18::getTotal() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return actualTotal;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ void Problem19::reset(){
|
||||
std::string Problem19::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return totalSundays;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void Problem2::reset(){
|
||||
std::string Problem2::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return fullSum;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void Problem20::reset(){
|
||||
std::string Problem20::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
//Print the results
|
||||
@@ -92,7 +92,7 @@ std::string Problem20::getString() const{
|
||||
mpz_class Problem20::getNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return num;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ mpz_class Problem20::getNumber() const{
|
||||
std::string Problem20::getNumberString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return num.get_str();
|
||||
}
|
||||
@@ -110,7 +110,7 @@ std::string Problem20::getNumberString() const{
|
||||
uint64_t Problem20::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void Problem21::reset(){
|
||||
std::string Problem21::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -119,7 +119,7 @@ std::string Problem21::getString() const{
|
||||
std::vector<uint64_t> Problem21::getAmicable() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return amicable;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ std::vector<uint64_t> Problem21::getAmicable() const{
|
||||
uint64_t Problem21::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return mee::getSum(amicable);
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ void Problem22::reset(){
|
||||
std::string Problem22::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
@@ -481,7 +481,7 @@ std::vector<std::string> Problem22::getNames() const{
|
||||
uint64_t Problem22::getNameScoreSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return mee::getSum(prod);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void Problem23::reset(){
|
||||
std::string Problem23::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The answer is " << sum;
|
||||
@@ -131,7 +131,7 @@ std::string Problem23::getString() const{
|
||||
uint64_t Problem23::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ void Problem24::reset(){
|
||||
std::string Problem24::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
//Print the results
|
||||
@@ -81,7 +81,7 @@ std::string Problem24::getString() const{
|
||||
std::vector<std::string> Problem24::getPermutationsList() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return permutations;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ std::vector<std::string> Problem24::getPermutationsList() const{
|
||||
std::string Problem24::getPermutation() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return permutations.at(NEEDED_PERM - 1);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ void Problem25::reset(){
|
||||
std::string Problem25::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -89,7 +89,7 @@ std::string Problem25::getString() const{
|
||||
mpz_class Problem25::getNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return number;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ mpz_class Problem25::getNumber() const{
|
||||
std::string Problem25::getNumberString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return number.get_str();
|
||||
}
|
||||
@@ -107,7 +107,7 @@ std::string Problem25::getNumberString() const{
|
||||
mpz_class Problem25::getIndex() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return index;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ mpz_class Problem25::getIndex() const{
|
||||
std::string Problem25::getIndexString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return index.get_str();
|
||||
}
|
||||
@@ -125,7 +125,7 @@ std::string Problem25::getIndexString() const{
|
||||
uint64_t Problem25::getIndexInt() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return index.get_ui();
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ void Problem26::reset(){
|
||||
std::string Problem26::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -118,7 +118,7 @@ std::string Problem26::getString() const{
|
||||
unsigned int Problem26::getLongestCycle() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return longestCycle;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ unsigned int Problem26::getLongestCycle() const{
|
||||
unsigned int Problem26::getLongestNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return longestNumber;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void Problem27::reset(){
|
||||
std::string Problem27::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -100,7 +100,7 @@ std::string Problem27::getString() const{
|
||||
int64_t Problem27::getTopA() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return topA;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ int64_t Problem27::getTopA() const{
|
||||
int64_t Problem27::getTopB() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return topB;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ int64_t Problem27::getTopB() const{
|
||||
int64_t Problem27::getTopN() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return topN;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ void Problem28::reset(){
|
||||
std::string Problem28::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -161,7 +161,7 @@ std::string Problem28::getString() const{
|
||||
std::vector<std::vector<int>> Problem28::getGrid() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ std::vector<std::vector<int>> Problem28::getGrid() const{
|
||||
uint64_t Problem28::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sumOfDiagonals;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void Problem29::reset(){
|
||||
std::string Problem29::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -100,7 +100,7 @@ std::string Problem29::getString() const{
|
||||
unsigned int Problem29::getBottomA() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return BOTTOM_A;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ unsigned int Problem29::getBottomA() const{
|
||||
unsigned int Problem29::getTopA() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return TOP_A;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ unsigned int Problem29::getTopA() const{
|
||||
unsigned int Problem29::getBottomB() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return BOTTOM_B;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ unsigned int Problem29::getBottomB() const{
|
||||
unsigned int Problem29::getTopB() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return TOP_B;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ unsigned int Problem29::getTopB() const{
|
||||
std::vector<mpz_class> Problem29::getUnique() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return unique;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ void Problem3::reset(){
|
||||
std::string Problem3::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return factors;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ std::vector<uint64_t> Problem3::getFactors() const{
|
||||
uint64_t Problem3::getLargestFactor() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
return *factors.end();
|
||||
@@ -98,7 +98,7 @@ uint64_t Problem3::getLargestFactor() const{
|
||||
uint64_t Problem3::getGoalNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return GOAL_NUMBER;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ void Problem30::reset(){
|
||||
std::string Problem30::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -110,7 +110,7 @@ std::string Problem30::getString() const{
|
||||
uint64_t Problem30::getTopNum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
return TOP_NUM;
|
||||
@@ -120,7 +120,7 @@ uint64_t Problem30::getTopNum() const{
|
||||
std::vector<uint64_t> Problem30::getListOfSumOfFifths() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
return sumOfFifthNumbers;
|
||||
@@ -130,7 +130,7 @@ std::vector<uint64_t> Problem30::getListOfSumOfFifths() const{
|
||||
uint64_t Problem30::getSumOfList() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
uint64_t sum = 0;
|
||||
|
||||
@@ -81,7 +81,7 @@ void Problem31::reset(){
|
||||
std::string Problem31::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -94,7 +94,7 @@ std::string Problem31::getString() const{
|
||||
int Problem31::getPermutations() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return permutations;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ void Problem4::reset(){
|
||||
std::string Problem4::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
//Print the results
|
||||
std::stringstream results;
|
||||
@@ -101,7 +101,7 @@ std::string Problem4::getString() const{
|
||||
std::vector<uint64_t> Problem4::getPalindromes() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return palindromes;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ std::vector<uint64_t> Problem4::getPalindromes() const{
|
||||
uint64_t Problem4::getLargestPalindrome() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return *(palindromes.end() - 1);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void Problem5::reset(){
|
||||
std::string Problem5::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return smallestNum;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void Problem6::reset(){
|
||||
std::string Problem6::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
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);
|
||||
@@ -83,7 +83,7 @@ std::string Problem6::getString() const{
|
||||
uint64_t Problem6::getSumOfSquares() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return sumOfSquares;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ uint64_t Problem6::getSumOfSquares() const{
|
||||
uint64_t Problem6::getSquareOfSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return squareOfSum;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ uint64_t Problem6::getSquareOfSum() const{
|
||||
uint64_t Problem6::getDifference() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return abs(sumOfSquares - squareOfSum);
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ void Problem67::reset(){
|
||||
std::string Problem67::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -339,7 +339,7 @@ std::string Problem67::getString() const{
|
||||
std::string Problem67::getPyramid() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
|
||||
@@ -356,7 +356,7 @@ std::string Problem67::getPyramid() const{
|
||||
std::string Problem67::getTrail(){
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
@@ -413,7 +413,7 @@ std::string Problem67::getTrail(){
|
||||
int Problem67::getTotal() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return actualTotal;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void Problem7::reset(){
|
||||
std::string Problem7::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
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{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return *primes.end();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void Problem8::reset(){
|
||||
std::string Problem8::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The greatest product is " << maxProduct
|
||||
@@ -111,7 +111,7 @@ std::string Problem8::getString() const{
|
||||
std::string Problem8::getLargestNums() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return maxNums;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ std::string Problem8::getLargestNums() const{
|
||||
uint64_t Problem8::getLargestProduct() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return maxProduct;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ void Problem9::reset(){
|
||||
std::string Problem9::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
if(found){
|
||||
@@ -101,7 +101,7 @@ std::string Problem9::getString() const{
|
||||
int Problem9::getSideA() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return a;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ int Problem9::getSideA() const{
|
||||
int Problem9::getSideB() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ int Problem9::getSideB() const{
|
||||
int Problem9::getSideC() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return (int)c;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ int Problem9::getSideC() const{
|
||||
int Problem9::getProduct() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw unsolved();
|
||||
throw Unsolved();
|
||||
}
|
||||
return a * b * (int)c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user