Updated to use new library layout

This commit is contained in:
2021-07-14 15:38:17 -04:00
parent ad2e948a42
commit b5c1df010f
39 changed files with 316 additions and 493 deletions

View File

@@ -1,7 +1,7 @@
//ProjectEulerTS/Problems/Problem18.ts
//Matthew Ellison
// Created: 04-05-21
//Modified: 04-05-21
//Modified: 07-14-21
//Find the maximum total from top to bottom
/*
75
@@ -40,7 +40,6 @@
*/
import { Unsolved } from "../Unsolved";
import { Problem } from "./Problem";
@@ -103,6 +102,7 @@ export class Problem18 extends Problem{
//Start the timer
this.timer.start();
//Invert the list
this.invert(workingList);
@@ -154,6 +154,7 @@ export class Problem18 extends Problem{
//Get the correct total which wil be the inversion of the current one
this.actualTotal = ((100 * workingList.length) - this.foundPoints[this.foundPoints.length - 1].total);
//Stop the timer
this.timer.stop();
@@ -170,25 +171,23 @@ export class Problem18 extends Problem{
//Gets
//Returns the result of solving the problem
public getResult(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `The value of the longest path is ${this.actualTotal}`;
}
//Returns the pyramid that was traversed as a string
public getPyramid(): string{
this.solvedCheck("pyramid of numbers");
return Problem18.list.toString();
}
//Returns the trail the algorithm took as a string
public getTrail(): string{
this.solvedCheck("trail of the shortest path");
//TODO:
return "";
}
//Returns the total that was asked for
public getTotal(): number{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("total");
return this.actualTotal;
}
}
@@ -208,6 +207,7 @@ class location{
}
}
/* Results:
The value of the longest path is 1074
It took an average of 134.407 microseconds to run this problem through 100 iterations