//ProjectEuler/C++/Headers/Problem17.hpp //Matthew Ellison // Created: 10-05-18 //Modified: 07-14-19 //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 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 the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef PROBLEM17_HPP #define PROBLEM17_HPP #include #include #include "Problem.hpp" class Problem17 : public Problem{ private: std::string makeWord(int num); std::string wordHelper(int num); uint64_t countLetters(std::string str); static int TOP_NUM; //This is the largest number to get the words of uint64_t letterCount; //This is the cumulative number of letters in the words of the numbers public: Problem17(); virtual void solve(); virtual std::string getString() const; virtual void reset(); //Returns the number of letters asked for uint64_t getLetterCount() const; }; /* Results: The number of letters is 21124 It took 217.500 microseconds to solve this problem. */ #endif //Problem17_HPP