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/Problem17.ts
//Matthew Ellison
// Created: 03-29-21
//Modified: 03-29-21
//Modified: 07-14-21
//If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
@@ -51,6 +51,7 @@ export class Problem17 extends Problem{
//Start the timer
this.timer.start();
//Start with 1 and increment
for(let num: number = Problem17.START_NUM;num <= Problem17.STOP_NUM;++num){
//Pass the number to a function that will create a string for the number
@@ -59,6 +60,7 @@ export class Problem17 extends Problem{
this.letterCount += this.getNumberChars(currentNumString);
}
//Stop the timer
this.timer.stop();
@@ -185,20 +187,17 @@ export class Problem17 extends Problem{
//Gets
//Returns the result of solving the problem
public getResult(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `The sum of all the letters in all the numbers ${Problem17.START_NUM}-${Problem17.STOP_NUM} is ${this.letterCount}`;
}
//Returns the number of letters asked for
public getLetterCount(): number{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("letter count");
return this.letterCount;
}
}
/* Results:
The sum of all the letters in all the numbers 1-1000 is 21124
It took an average of 485.744 microseconds to run this problem through 100 iterations