Updated to use new library layout

This commit is contained in:
2021-07-24 16:13:05 -04:00
parent d18b3fa9f6
commit 84555edd31
39 changed files with 515 additions and 709 deletions

View File

@@ -1,11 +1,11 @@
#ProjectEuler/Python/Problem15.py
#Matthew Ellison
# Created: 01-31-19
#Modified: 10-30-20
#Modified: 07-24-21
#How many routes from the top left corner to the bottom right corner are there through a 20×20 grid if you can only move right and down?
#Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses
"""
Copyright (C) 2020 Matthew Ellison
Copyright (C) 2021 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -23,7 +23,6 @@
from Problems.Problem import Problem
from Unsolved import Unsolved
class Problem15(Problem):
@@ -33,13 +32,13 @@ class Problem15(Problem):
#Functions
#Constructor
def __init__(self):
def __init__(self) -> None:
super().__init__("How many routes from the top left corner to the bottom right corner are there through a 20x20 grid if you can only move right and down?")
self.numOfRoutes = 0
#Operational functions
#Solve the problem
def solve(self):
def solve(self) -> None:
#If the problem has already been solved do nothing and end the function
if(self.solved):
return
@@ -47,9 +46,11 @@ class Problem15(Problem):
#Start the timer
self.timer.start()
#Start the recursion at the right location and catch what is returned
self.numOfRoutes = self.movement(0, 0)
#Stop the timer
self.timer.stop()
@@ -75,22 +76,18 @@ class Problem15(Problem):
return numberMoves
#Reset the problem so it can be run again
def reset(self):
def reset(self) -> None:
super().reset()
self.numOfRoutes = 0
#Gets
#Returns the result of solving the problem
def getResult(self):
#If the problem hasn't been solved throw an exception
if(not self.solved):
raise Unsolved("You must solve the problem before you can see the result")
def getResult(self) -> str:
self.solvedCheck("result")
return f"The number of paths from 1 corner of a {self.__gridWidth} x {self.__gridHeight} grid to the opposite corner is {self.numOfRoutes}"
#Returns the number of routes found
def getNumberOfRoutes(self) -> int:
#If the problem hasn't been solved throw an exception
if(not self.solved):
raise Unsolved("You must solve the problem before you can get the number of routes")
self.solvedCheck("number of routes")
return self.numOfRoutes