mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Changed Problem 67 to work with 18
This commit is contained in:
@@ -58,13 +58,10 @@ private:
|
||||
int yLocation;
|
||||
int total;
|
||||
bool fromRight;
|
||||
location(int x, int y, int t, bool r) : xLocation(x), yLocation(y), total(t), fromRight(r){ }
|
||||
location(int x, int y, int t, bool r) : xLocation(x), yLocation(y), total(t), fromRight(r){}
|
||||
};
|
||||
|
||||
//Variables
|
||||
//Static variables
|
||||
static const int NUM_ROWS = 15; //The number of rows in the array
|
||||
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
|
||||
@@ -72,6 +69,11 @@ private:
|
||||
|
||||
//Functions
|
||||
void invert(); //This list turns every number in the vector into 100 - num
|
||||
void setupList();
|
||||
protected:
|
||||
//Variables
|
||||
//Static variables
|
||||
static std::vector<std::vector<int>> list; //Setup the list you are trying to find a path through
|
||||
public:
|
||||
//Constructor
|
||||
Problem18();
|
||||
|
||||
@@ -128,43 +128,18 @@ Find the maximum total from top to bottom
|
||||
#define PROBLEM67_HPP
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include "Problem.hpp"
|
||||
#include "Problem18.hpp"
|
||||
|
||||
|
||||
class Problem67 : public Problem{
|
||||
class Problem67 : public Problem18{
|
||||
//This class does exactly the same thing as 18, all we need to do is update the list that is searched through
|
||||
private:
|
||||
//Structures
|
||||
struct location{
|
||||
int xLocation;
|
||||
int yLocation;
|
||||
int total;
|
||||
bool fromRight;
|
||||
location(int x, int y, int t, bool r) : xLocation(x), yLocation(y), total(t), fromRight(r){ }
|
||||
};
|
||||
//Variables
|
||||
//Static variables
|
||||
static const int NUM_ROWS = 100; //The number of rows in the list of numbers
|
||||
static std::vector<int> list[NUM_ROWS]; //This is 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 function takes every number in the vector and changes it to 100 - the number
|
||||
void setupList();
|
||||
public:
|
||||
//Constructor
|
||||
Problem67();
|
||||
//Operational functions
|
||||
virtual void solve(); //Solve the problem
|
||||
virtual void reset(); //Reset the problem so it can be run again
|
||||
//Gets
|
||||
std::string getPyramid() const; //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
|
||||
Problem67() : Problem18(){
|
||||
list.clear();
|
||||
setupList();
|
||||
}
|
||||
};
|
||||
|
||||
/* Results:
|
||||
|
||||
Reference in New Issue
Block a user