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/Problem11.ts
//Matthew Ellison
// Created: 03-24-21
//Modified: 03-24-21
//Modified: 07-14-21
//Find the sum of all the primes below two million
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
@@ -23,8 +23,7 @@
import { Problem } from "./Problem";
import { Unsolved } from "../Unsolved";
import { getProd } from "../../../Typescript/typescriptClasses/Algorithms";
import { getProd } from "../../../Typescript/typescriptClasses/ArrayAlgorithms";
export class Problem11 extends Problem{
@@ -80,6 +79,7 @@ export class Problem11 extends Problem{
//Start the timer
this.timer.start();
//Loop through every row and column
for(let row = 0;row < Problem11.grid.length;++row){
for(let col = 0;col < Problem11.grid[row].length;++col){
@@ -155,6 +155,7 @@ export class Problem11 extends Problem{
}
}
//Stop the timer
this.timer.stop();
@@ -169,30 +170,22 @@ export class Problem11 extends Problem{
//Gets
//Returns the result of solving the problem
public getResult(): string{
//If the problem hasn't been solved throw an exception
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `The greatest product of 4 numbers in a line is ${getProd(this.greatestProduct)}\nThe numbers are ${this.greatestProduct}`;
}
//Returns the numbers that were being searched
public getNumbers(): number[]{
//If the problem hasn't been solved throw an exception
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("numbers");
return this.greatestProduct;
}
//Returns teh product that was requested
public getProduct(): number{
//If the problem hasn't been solved throw an exception
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("product of the numbers");
return getProd(this.greatestProduct);
}
}
/* Results:
The greatest product of 4 numbers in a line is 70600674
The numbers are 89,94,97,87