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/Problem22.ts
//Matthew Ellison
// Created: 04-08-21
//Modified: 04-08-21
//Modified: 07-14-21
//What is the total of all the name scores in this file?
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
@@ -21,8 +21,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { getSum } from "../../../Typescript/typescriptClasses/Algorithms";
import { Unsolved } from "../Unsolved";
import { getSum } from "../../../Typescript/typescriptClasses/ArrayAlgorithms";
import { Problem } from "./Problem";
@@ -422,6 +422,7 @@ export class Problem22 extends Problem{
//Start the timer
this.timer.start();
//Sort all the names
Problem22.names.sort();
//Step through every name adding up the values of the characters
@@ -440,6 +441,7 @@ export class Problem22 extends Problem{
//Get the sum of all the numbers
this.sum = getSum(this.prod);
//Stop the timer
this.timer.stop();
@@ -456,9 +458,7 @@ export class Problem22 extends Problem{
//Gets
//Returns the result of solving the problem
public getResult(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `The answer to the question is ${this.sum}`;
}
//Returns the vector of the names being scored
@@ -467,13 +467,12 @@ export class Problem22 extends Problem{
}
//Returns the sum of the names scores
public getNameScoreSum(): number{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("score of the names");
return this.sum;
}
}
/* Results:
The answer to the question is 871198282
It took an average of 473.266 microseconds to run this problem through 100 iterations