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/Problem28.ts
//Matthew Ellison
// Created: 05-26-21
//Modified: 05-26-21
//Modified: 07-14-21
//What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed by starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral
//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";
@@ -122,11 +121,13 @@ export class Problem28 extends Problem{
//Start the timer
this.timer.start();
//Setup the grid
this.setupGrid();
//FInd the sum of the diagonals in the grid
this.findSum();
//Stop the timer
this.timer.stop();
@@ -141,29 +142,22 @@ export class Problem28 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 the diagonals in the given grid is ${this.sumOfDiagonals}`;
}
//Returns the grid
public getGrid(): number[][]{
//IF the problem hasn't been solved throw an exception
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("grid");
return Problem28.grid;
}
//Returns the sum of the diagonals
public getSum(): number{
//If the problem hasn't been solved throw an exception
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("sum");
return this.sumOfDiagonals;
}
}
/* Results:
The sum of the diagonals in the given grid is 669171001
It took an average of 16.924 milliseconds to run this problem through 100 iterations