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++/Headers/Problem17.hpp
|
||||
//ProjectEuler/ProjectEulerCPP/Headers/Problem17.hpp
|
||||
//Matthew Ellison
|
||||
// Created: 10-05-18
|
||||
//Modified: 07-14-19
|
||||
//Modified: 07-09-20
|
||||
//If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
|
||||
//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
|
||||
@@ -32,23 +32,29 @@
|
||||
|
||||
class Problem17 : public Problem{
|
||||
private:
|
||||
std::string makeWord(int num);
|
||||
std::string wordHelper(int num);
|
||||
uint64_t countLetters(std::string str);
|
||||
|
||||
//Variables
|
||||
//Static variables
|
||||
static int TOP_NUM; //This is the largest number to get the words of
|
||||
//Instance variables
|
||||
uint64_t letterCount; //This is the cumulative number of letters in the words of the numbers
|
||||
|
||||
//Functions
|
||||
std::string makeWord(int num); //This function makes a word out of the number passed into it
|
||||
std::string wordHelper(int num); //This function helps makeWord() by returning the words for the numbers 1-9
|
||||
uint64_t countLetters(std::string str); //This counts the number of letters in the string that is passed in (ignoring numbers and punctuation)
|
||||
public:
|
||||
//Constructor
|
||||
Problem17();
|
||||
virtual void solve();
|
||||
virtual std::string getString() const;
|
||||
virtual void reset();
|
||||
//Returns the number of letters asked for
|
||||
uint64_t getLetterCount() const;
|
||||
//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 getLetterCount() const; //Returns the number of letters asked for
|
||||
};
|
||||
/* Results:
|
||||
The number of letters is 21124
|
||||
It took 217.500 microseconds to solve this problem.
|
||||
It took an average of 220.126 microseconds to run this problem over 100 iterations
|
||||
*/
|
||||
|
||||
#endif //Problem17_HPP
|
||||
|
||||
Reference in New Issue
Block a user