//ProjectEuler/C++/Headers/Problem19.hpp //Matthew Ellison // Created: 09-28-18 //Modified: 07-14-19 //How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? /* You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. */ //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 PROBLEM19_HPP #define PROBLEM19_HPP #include #include #include "Problem.hpp" class Problem19 : public Problem{ private: //Variables //An easier way to return the days enum DAYS {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, NUMBER_OF_DAYS, ERROR}; static unsigned int START_YEAR; //The start year static unsigned int END_YEAR; //The stop year uint64_t totalSundays; //Keep track of the number of sundays //Functions //Return the day of the week that the date you pass into it is on DAYS getDay(unsigned int month, unsigned int day, unsigned int year); //Returns true if the year passed to it is a leap year bool isLeapYear(unsigned int year); public: Problem19(); virtual void solve(); virtual std::string getString() const; virtual void reset(); //Returns the total sundays that were asked for uint64_t getTotalSundays() const; }; /* Results There are 171 Sundays that landed on the first of the months from 1901 to 2000 It took 4.579 milliseconds to solve this problem. */ #endif //PROBLEM19_HPP