mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated comments and made sure style was consistent
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//ProjectEuler/C++/Source/Problem30.cpp
|
||||
//ProjectEuler/ProjectEulerCPP/Source/Problem30.cpp
|
||||
//Matthew Ellison
|
||||
// Created: 10-27-19
|
||||
//Modified: 10-27-19
|
||||
//Modified: 07-09-20
|
||||
//Find the sum of all the numbers that can be written as the sum of the fifth powers of their digits.
|
||||
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
|
||||
/*
|
||||
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
|
||||
@@ -30,8 +30,12 @@
|
||||
#include "../Headers/Problem30.hpp"
|
||||
|
||||
|
||||
Problem30::Problem30() : Problem("Find the sum of all the numbers that can be written as a sum of the fifth powers of their digits"){
|
||||
}
|
||||
//This is the largest number that will be checked
|
||||
uint64_t Problem30::TOP_NUM = 1000000;
|
||||
//Start with 2 because 0 and 1 don't count
|
||||
uint64_t Problem30::BOTTOM_NUM = 2;
|
||||
//This is the power that the digits are raised to
|
||||
uint64_t Problem30::POWER_RAISED = 5;
|
||||
|
||||
//Returns a vector with the indivitual digits of the number passed into it
|
||||
std::vector<uint64_t> Problem30::getDigits(uint64_t num){
|
||||
@@ -46,6 +50,11 @@ std::vector<uint64_t> Problem30::getDigits(uint64_t num){
|
||||
return listOfDigits;
|
||||
}
|
||||
|
||||
//Constructor
|
||||
Problem30::Problem30() : Problem("Find the sum of all the numbers that can be written as a sum of the fifth powers of their digits"){
|
||||
}
|
||||
|
||||
//Solve the problem
|
||||
void Problem30::solve(){
|
||||
//If the problem has already been solved do nothing and end the function
|
||||
if(solved){
|
||||
@@ -78,6 +87,13 @@ void Problem30::solve(){
|
||||
solved = true;
|
||||
}
|
||||
|
||||
//Reset the problem so it can be run again
|
||||
void Problem30::reset(){
|
||||
Problem::reset();
|
||||
sumOfFifthNumbers.clear();
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem30::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
@@ -124,8 +140,3 @@ uint64_t Problem30::getSumOfList() const{
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
void Problem30::reset(){
|
||||
Problem::reset();
|
||||
sumOfFifthNumbers.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user