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/Problem29.ts
//Matthew Ellison
// Created: 05-28-21
//Modified: 05-28-21
//Modified: 07-14-21
//How many distinct terms are in the sequence generated by a^b for 2 <= a <= 100 and 2 <= b <= 100?
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
@@ -22,7 +22,6 @@
*/
import { Unsolved } from "../Unsolved";
import { Problem } from "./Problem";
@@ -53,6 +52,7 @@ export class Problem29 extends Problem{
//Start the timer
this.timer.start();
//Start witht he first A and move towards the top
for(let currentA = Problem29.BOTTOM_A;currentA <= Problem29.TOP_A;++currentA){
//Start with the first B and move towards the top
@@ -66,6 +66,7 @@ export class Problem29 extends Problem{
}
}
//Stop the timer
this.timer.stop();
@@ -80,9 +81,7 @@ export class Problem29 extends Problem{
//Gets
//Returns the result of solving the problem
public getResult(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `The number of unique values generated by a^b for ${Problem29.BOTTOM_A} <= a <= ${Problem29.TOP_A} and ${Problem29.BOTTOM_B} <= b <= ${Problem29.TOP_B} is ${this.unique.length}`;
}
//Returns the lowest possible value for a
@@ -103,14 +102,17 @@ export class Problem29 extends Problem{
}
//Returns a list of all the unique values for a^b
public getUnique(): bigint[]{
//If the problem hasn't been solved throw an exception
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("unique values for a^b");
return this.unique;
}
//Returns the number of unique values for a^b
public getNumUnique(): number{
this.solvedCheck("number of unique values for a^b");
return this.unique.length;
}
}
/* Results:
The number of unique values generated by a^b for 2 <= a <= 100 and 2 <= b <= 100 is 9183
It took an average of 349.571 milliseconds to run this problem through 100 iterations