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/Problem31.ts
|
||||
//Matthew Ellison
|
||||
// Created: 05-28-21
|
||||
//Modified: 05-28-21
|
||||
//Modified: 07-14-21
|
||||
//How many different ways can £2 be made using any number of coins?
|
||||
//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";
|
||||
|
||||
|
||||
@@ -50,6 +49,7 @@ export class Problem31 extends Problem{
|
||||
//Start the timer
|
||||
this.timer.start();
|
||||
|
||||
|
||||
//Start with 200p and remove the necessary coins with each loop
|
||||
for(let pound2 = Problem31.DESIRED_VALUE;pound2 >= 0;pound2 -= 200){
|
||||
for(let pound1 = pound2;pound1 >= 0;pound1 -= 100){
|
||||
@@ -67,6 +67,7 @@ export class Problem31 extends Problem{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Stop the timer
|
||||
this.timer.stop();
|
||||
|
||||
@@ -81,21 +82,17 @@ export class Problem31 extends Problem{
|
||||
//Gets
|
||||
//Returns the result of solving the proble
|
||||
public getResult(): string{
|
||||
if(!this.solved){
|
||||
throw new Unsolved();
|
||||
}
|
||||
this.solvedCheck("result");
|
||||
return `There are ${this.permutations} ways to make 2 pounds with the given denominations of coins`;
|
||||
}
|
||||
//Returns the number of correct permutations of the coins
|
||||
public getPermutations(): number{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!this.solved){
|
||||
throw new Unsolved();
|
||||
}
|
||||
this.solvedCheck("number of correct permutations of the coins");
|
||||
return this.permutations;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Results:
|
||||
There are 73682 ways to make 2 pounds with the given denominations of coins
|
||||
It took an average of 197.293 microseconds to run this problem through 100 iterations
|
||||
|
||||
Reference in New Issue
Block a user