mirror of
https://bitbucket.org/Mattrixwv/projecteulerts.git
synced 2025-12-06 17:43:59 -05:00
Updated to use new library layout
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//ProjectEulerTS/Problems/Problem18.ts
|
||||
//Matthew Ellison
|
||||
// Created: 04-06-21
|
||||
//Modified: 04-06-21
|
||||
//Modified: 07-14-21
|
||||
//How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
|
||||
/*
|
||||
You are given the following information, but you may prefer to do some research for yourself.
|
||||
@@ -33,7 +33,6 @@ A leap year occurs on any year evenly divisible by 4, but not on a century unles
|
||||
*/
|
||||
|
||||
|
||||
import { Unsolved } from "../Unsolved";
|
||||
import { Problem } from "./Problem";
|
||||
|
||||
|
||||
@@ -66,6 +65,7 @@ export class Problem19 extends Problem{
|
||||
//Start the timer
|
||||
this.timer.start();
|
||||
|
||||
|
||||
//Run for all years 1901-2000
|
||||
for(let year = Problem19.START_YEAR;year <= Problem19.END_YEAR;++year){
|
||||
//Run for all months in the year
|
||||
@@ -80,6 +80,7 @@ export class Problem19 extends Problem{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Stop the timer
|
||||
this.timer.stop();
|
||||
|
||||
@@ -194,20 +195,17 @@ export class Problem19 extends Problem{
|
||||
//Gets
|
||||
//Returns the result of solving the problem
|
||||
public getResult(): string{
|
||||
if(!this.solved){
|
||||
throw new Unsolved();
|
||||
}
|
||||
this.solvedCheck("result");
|
||||
return `There are ${this.totalSundays} Sundays that landed on the first of the months from ${Problem19.START_YEAR} to ${Problem19.END_YEAR}`;
|
||||
}
|
||||
//Returns the total sundays that were asked for
|
||||
public getTotalSundays(): number{
|
||||
if(!this.solved){
|
||||
throw new Unsolved();
|
||||
}
|
||||
this.solvedCheck("total number of sundays");
|
||||
return this.totalSundays;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Results:
|
||||
There are 171 Sundays that landed on the first of the months from 1901 to 2000
|
||||
It took an average of 4.314 milliseconds to run this problem through 100 iterations
|
||||
|
||||
Reference in New Issue
Block a user