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/Problem32.ts
//Matthew Ellison
// Created: 05-28-21
//Modified: 05-28-21
//Modified: 07-14-21
//Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital.
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
@@ -22,8 +22,7 @@
*/
import { findNumOccurrence } from "../../../Typescript/typescriptClasses/Algorithms";
import { Unsolved } from "../Unsolved";
import { findNumOccurrence } from "../../../Typescript/typescriptClasses/StringAlgorithms";
import { Problem } from "./Problem";
@@ -85,6 +84,7 @@ export class Problem32 extends Problem{
//Start the timer
this.timer.start();
//Create the multiplicand and start working your way up
for(let multiplicand = 1;multiplicand <= Problem32.TOP_MULTIPLICAND;++multiplicand){
//Run through all possible multipliers
@@ -108,6 +108,7 @@ export class Problem32 extends Problem{
this.sumOfPandigitals += prod.getProduct();
}
//Stop the timer
this.timer.stop();
@@ -140,21 +141,17 @@ export class Problem32 extends Problem{
}
//Gets
public getResult(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `There are ${this.listOfProducts.length} unique 1-9 pandigitals\nThe sum of the products of the pandigitals is ${this.sumOfPandigitals}`
}
//Returns the sum of pandigitals
public getSumOfPandigitlas(): number{
//If the problem hasn't been solved throw an exception
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("sum of the pandigitals");
return this.sumOfPandigitals;
}
}
/* Results:
There are 7 unique 1-9 pandigitals
The sum of the products of the pandigitals is 45228