mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Updated comments and made sure style was consistent
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//ProjectEuler/C++/Headers/Problem30.hpp
|
||||
//ProjectEuler/ProjectEulerCPP/Headers/Problem30.hpp
|
||||
//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
|
||||
@@ -33,16 +33,24 @@
|
||||
|
||||
class Problem30 : public Problem{
|
||||
private:
|
||||
static const uint64_t TOP_NUM = 1000000; //This is the largest number that will be checked
|
||||
static const uint64_t BOTTOM_NUM = 2; //Start with 2 because 0 and 1 don't count
|
||||
static const uint64_t POWER_RAISED = 5; //This is the power that the digits are raised to
|
||||
//Variables
|
||||
//Static variables
|
||||
static uint64_t TOP_NUM; //This is the largest number that will be checked
|
||||
static uint64_t BOTTOM_NUM; //Start with 2 because 0 and 1 don't count
|
||||
static uint64_t POWER_RAISED; //This is the power that the digits are raised to
|
||||
//Instance variables
|
||||
std::vector<uint64_t> sumOfFifthNumbers; //This is a vector of the numbers that are the sum of the fifth power of their digits
|
||||
|
||||
//Functions
|
||||
std::vector<uint64_t> getDigits(uint64_t num); //Returns a vector with the indivitual digits of the number passed into it
|
||||
public:
|
||||
//Constructor
|
||||
Problem30();
|
||||
virtual void solve();
|
||||
virtual std::string getString() const;
|
||||
virtual void reset();
|
||||
//Operational functions
|
||||
virtual void solve(); //Solve the problem
|
||||
virtual void reset(); //Reset the problem so it can be run again
|
||||
//Gets
|
||||
virtual std::string getString() const; //Return a string with the solution to the problem
|
||||
uint64_t getTopNum() const; //This returns the top number to be checked
|
||||
std::vector<uint64_t> getListOfSumOfFifths() const; //This returns a copy of the vector holding all the numbers that are the sum of the fifth power of their digits
|
||||
uint64_t getSumOfList() const; //This returns the sum of all entries in sumOfFifthNumbers
|
||||
@@ -51,7 +59,7 @@ public:
|
||||
|
||||
/* Results:
|
||||
The sum of all the numbers that can be written as the sum of the fifth powers of their digits is 443839
|
||||
It took 280.300 milliseconds to solve this problem.
|
||||
It took an average of 306.944 milliseconds to run this problem over 100 iterations
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user