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,7 +1,7 @@
//ProjectEuler/C++/Source/Problem67.cpp
//ProjectEuler/ProjectEulerCPP/Source/Problem67.cpp
//Matthew Ellison
// Created: 11-02-18
//Modified: 07-14-19
//Modified: 07-09-20
//The way to do this is using a breadth first search
/*
Find the maximum total from top to bottom
@@ -108,7 +108,7 @@ Find the maximum total from top to bottom
*/
//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
@@ -133,6 +133,7 @@ Find the maximum total from top to bottom
#include "../Headers/Problem67.hpp"
//This is the list you are trying to find a path through
std::vector<int> Problem67::list[NUM_ROWS] = {
{59},
{73, 41},
@@ -236,9 +237,7 @@ std::vector<int> Problem67::list[NUM_ROWS] = {
{23, 33, 44, 81, 80, 92, 93, 75, 94, 88, 23, 61, 39, 76, 22, 03, 28, 94, 32, 06, 49, 65, 41, 34, 18, 23, 8, 47, 62, 60, 03, 63, 33, 13, 80, 52, 31, 54, 73, 43, 70, 26, 16, 69, 57, 87, 83, 31, 03, 93, 70, 81, 47, 95, 77, 44, 29, 68, 39, 51, 56, 59, 63, 07, 25, 70, 07, 77, 43, 53, 64, 03, 94, 42, 95, 39, 18, 01, 66, 21, 16, 97, 20, 50, 90, 16, 70, 10, 95, 69, 29, 06, 25, 61, 41, 26, 15, 59, 63, 35},
};
Problem67::Problem67() : Problem("Find the maximum total from the top to the bottom of the pyramid."){
}
//This function takes every number in the vector and changes it to 100 - the number
void Problem67::invert(){
for(unsigned int rowCnt = 0;rowCnt < NUM_ROWS;++rowCnt){
for(unsigned int colCnt = 0;colCnt < list[rowCnt].size();++colCnt){
@@ -247,6 +246,11 @@ void Problem67::invert(){
}
}
//Constructor
Problem67::Problem67() : Problem("Find the maximum total from the top to the bottom of the pyramid."){
}
//Solve the problem
void Problem67::solve(){
//If the problem has already been solved do nothing and end the function
if(solved){
@@ -311,6 +315,15 @@ void Problem67::solve(){
solved = true;
}
//Clears all of the variables so the problem can be run again
void Problem67::reset(){
Problem::reset();
foundPoints.clear();
possiblePoints.clear();
actualTotal = 0;
}
//Return a string with the solution to the problem
std::string Problem67::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -404,11 +417,3 @@ int Problem67::getTotal() const{
}
return actualTotal;
}
//Clears all of the variables so the problem can be run again
void Problem67::reset(){
Problem::reset();
foundPoints.clear();
possiblePoints.clear();
actualTotal = 0;
}