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++/Headers/Problem18.hpp
//ProjectEuler/ProjectEulerCPP/Headers/Problem18.hpp
//Matthew Ellison
// Created: 11-01-18
//Modified: 07-14-19
//Modified: 07-09-20
//Find the maximum total from top to bottom
/*
75
@@ -23,7 +23,7 @@
//This is done using a breadth first search
//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
@@ -51,6 +51,8 @@
class Problem18 : public Problem{
private:
//Structures
//A structure to hold the location data for a point on the map
struct location{
int xLocation;
int yLocation;
@@ -58,30 +60,34 @@ private:
bool fromRight;
location(int x, int y, int t, bool r) : xLocation(x), yLocation(y), total(t), fromRight(r){ }
};
//This list turns every number in the vector into 100 - num
void invert();
//Variables
//Static variables
static const int NUM_ROWS = 15; //The number of rows in the array
//Setup the list you are trying to find a path through
static std::vector<int> list[NUM_ROWS];
static std::vector<int> list[NUM_ROWS]; //Setup the list you are trying to find a path through
//Instance variables
std::list<location> foundPoints; //For the points that I have already found the shortest distance to
std::list<location> possiblePoints; //For the locations you are checking this round
int actualTotal; //The true total of the path from the top to the bottom
//Functions
void invert(); //This list turns every number in the vector into 100 - num
public:
//Constructor
Problem18();
virtual void solve();
virtual std::string getString() const;
virtual void reset();
//Returns the pyramid that was traversed as a string
std::string getPyramid();
//Returns the trail the algorithm took as a string
std::string getTrail();
//Returns the total that was asked for
int getTotal() 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
std::string getPyramid(); //Returns the pyramid that was traversed as a string
std::string getTrail(); //Returns the trail the algorithm took as a string
int getTotal() const; //Returns the total that was asked for
};
/* Results:
The value of the longest path is 1074
It took 16.500 microseconds to solve this problem.
It took an average of 9.925 microseconds to run this problem over 100 iterations
*/
#endif //PROBLEM18_HPP