Updated comments and made sure style was consistent

This commit is contained in:
2020-07-10 13:36:16 -04:00
parent 7257a118d4
commit c72754dcf8
65 changed files with 1160 additions and 747 deletions

View File

@@ -1,10 +1,10 @@
//ProjectEuler/C++/Source/Problem12.cpp
//ProjectEuler/ProjectEulerCPP/Source/Problem12.cpp
//Matthew Ellison
// Created: 09-27-18
//Modified: 07-14-19
//Modified: 07-09-20
//What is the value of the first triangle number to have over five hundred divisors?
//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,11 +30,14 @@
#include "../Headers/Problem12.hpp"
//The number of divisors that you want
uint64_t Problem12::GOAL_DIVISORS = 500;
//Constructor
Problem12::Problem12() : Problem("What is the value of the first triangle number to have over five hundred divisors?"), sum(1), counter(2){
}
//Solve the problem
void Problem12::solve(){
//If the problem has already been solved do nothing and end the function
if(solved){
@@ -67,6 +70,15 @@ void Problem12::solve(){
solved = true;
}
//Reset the problem so it can be run again
void Problem12::reset(){
Problem::reset();
divisors.clear();
sum = 1;
counter = 2;
}
//Return a string with the solution to the problem
std::string Problem12::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -77,6 +89,7 @@ std::string Problem12::getString() const{
return results.str();
}
//Returns the triangular number
int64_t Problem12::getTriangularNumber() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -85,6 +98,7 @@ int64_t Problem12::getTriangularNumber() const{
return sum;
}
//Get the final number that was added to the triangular number
int64_t Problem12::getLastNumberAdded() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -93,6 +107,7 @@ int64_t Problem12::getLastNumberAdded() const{
return counter - 1;
}
//Returns the list of divisors of the requested number
std::vector<int64_t> Problem12::getDivisorsOfTriangularNumber() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -101,6 +116,7 @@ std::vector<int64_t> Problem12::getDivisorsOfTriangularNumber() const{
return divisors;
}
//Returns the number of divisors of the requested number
size_t Problem12::getNumberOfDivisors() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -108,10 +124,3 @@ size_t Problem12::getNumberOfDivisors() const{
}
return divisors.size();
}
void Problem12::reset(){
Problem::reset();
divisors.clear();
sum = 1;
counter = 2;
}