mirror of
https://bitbucket.org/Mattrixwv/projecteulerpython.git
synced 2025-12-06 17:43:58 -05:00
Removed unneccessary imports
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ProjectEuler/Python/Problem1.py
|
||||
#Matthew Ellison
|
||||
# Created: 01-26-19
|
||||
#Modified: 10-26-20
|
||||
#Modified: 10-29-20
|
||||
#What is the sum of all the multiples of 3 or 5 that are less than 1000
|
||||
#Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ProjectEuler/Python/Problem2.py
|
||||
#Matthew Ellison
|
||||
# Created: 01-26-19
|
||||
#Modified: 07-17-20
|
||||
#Modified: 10-29-20
|
||||
#The sum of the even Fibonacci numbers less than 4,000,000
|
||||
#Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses
|
||||
"""
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
|
||||
from Problems.Problem import Problem
|
||||
from Stopwatch import Stopwatch
|
||||
from Algorithms import getAllFib
|
||||
from Unsolved import Unsolved
|
||||
|
||||
@@ -77,6 +76,7 @@ class Problem2(Problem):
|
||||
raise Unsolved("You must solve the problem before can you see the sum")
|
||||
return self.fullSum
|
||||
|
||||
|
||||
#If you are running this file, automatically start the correct function
|
||||
if __name__ == '__main__':
|
||||
problem = Problem2() #Call the function that answers the question
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ProjectEuler/Python/Problem3.py
|
||||
#Matthew Ellison
|
||||
# Created: 01-27-19
|
||||
#Modified: 07-17-20
|
||||
#Modified: 10-29-20
|
||||
#The largest prime factor of 600851475143
|
||||
#Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses
|
||||
"""
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
|
||||
from Problems.Problem import Problem
|
||||
from Stopwatch import Stopwatch
|
||||
from Algorithms import getFactors
|
||||
from Unsolved import Unsolved
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ProjectEuler/Python/Problem4.py
|
||||
#Matthew Ellison
|
||||
# Created: 01-28-19
|
||||
#Modified: 07-17-20
|
||||
#Modified: 10-29-20
|
||||
#Find the largest palindrome made from the product of two 3-digit numbers
|
||||
#Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses
|
||||
"""
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
|
||||
from Problems.Problem import Problem
|
||||
from Stopwatch import Stopwatch
|
||||
from Unsolved import Unsolved
|
||||
|
||||
|
||||
@@ -88,6 +87,7 @@ class Problem4(Problem):
|
||||
raise Unsolved("You must solve the problem before you can get the largest palindrome")
|
||||
return self.palindromes[len(self.palindromes) - 1]
|
||||
|
||||
|
||||
#If you are running this file, automatically start the correct function
|
||||
if __name__ == '__main__':
|
||||
problem = Problem4()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ProjectEulter/Python/Project5.py
|
||||
#Matthew Ellison
|
||||
# Created: 01-28-19
|
||||
#Modified: 07-17-20
|
||||
#Modified: 10-29-20
|
||||
#What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
|
||||
#Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses
|
||||
"""
|
||||
@@ -23,14 +23,13 @@
|
||||
|
||||
|
||||
from Problems.Problem import Problem
|
||||
from Stopwatch import Stopwatch
|
||||
from Unsolved import Unsolved
|
||||
|
||||
|
||||
class Problem5(Problem):
|
||||
#Variables
|
||||
__startNum = 1
|
||||
__stopNum = 20
|
||||
__startDivisor = 1
|
||||
__stopDivisor = 20
|
||||
|
||||
#Functions
|
||||
#Constructor
|
||||
@@ -56,7 +55,7 @@ class Problem5(Problem):
|
||||
#Set that it found the number to true, because it sets this flag when it doesn't find it
|
||||
numFound = True
|
||||
#See if the current number is divisible by all numbers from 1 to 20
|
||||
for divisor in range(self.__startNum, self.__stopNum + 1):
|
||||
for divisor in range(self.__startDivisor, self.__stopDivisor + 1):
|
||||
#If it is not set a flag to move to the next possible number
|
||||
if((currentNum % divisor) != 0):
|
||||
numFound = False
|
||||
@@ -66,6 +65,7 @@ class Problem5(Problem):
|
||||
if(not numFound):
|
||||
currentNum += 2
|
||||
|
||||
#Set the smallest number to the number we just found
|
||||
self.smallestNum = currentNum
|
||||
|
||||
#Stop the timer
|
||||
@@ -92,6 +92,7 @@ class Problem5(Problem):
|
||||
raise Unsolved("You must solve the problem before you can get the requested number")
|
||||
return self.smallestNum
|
||||
|
||||
|
||||
#If it are running this file, automatically start the correct function
|
||||
if __name__ == '__main__':
|
||||
problem = Problem5()
|
||||
@@ -104,4 +105,4 @@ if __name__ == '__main__':
|
||||
"""Results:
|
||||
The smallest positive number that is evenly divisible by all numbers 1-20 is 232792560
|
||||
It took an average of 54.833 seconds to run this problem through 100 iterations
|
||||
"""
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user