mirror of
https://bitbucket.org/Mattrixwv/projecteulerts.git
synced 2025-12-06 17:43:59 -05:00
Updated to use new library layout
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user