mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Commented doctests that were causing slowness at Travis. (#1039)
* Added doctest and more explanation about Dijkstra execution. * tests were not passing with python2 due to missing __init__.py file at number_theory folder * Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules. * Moved global code to main scope and added doctest for project euler problems 1 to 14. * Added test case for negative input. * Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone. * Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts. * Changed the way files are loaded to support pytest call. * Added __init__.py to problems to make them modules and allow pytest execution. * Added project_euler folder to test units execution * Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()' * Added Burrows-Wheeler transform algorithm. * Added changes suggested by cclauss * Fixes for issue 'Fix the LGTM issues #1024'. * Added doctest for different parameter types and negative values. * Fixed doctest issue added at last commit. * Commented doctest that were causing slowness at Travis. * Added comment with the reason for some doctest commented. * pytest --ignore
This commit is contained in:
committed by
cclauss
parent
9f8953dc0c
commit
f7ac8b5ed0
@@ -18,8 +18,9 @@ def solution():
|
||||
2. a**2 + b**2 = c**2
|
||||
3. a + b + c = 1000
|
||||
|
||||
>>> solution()
|
||||
31875000
|
||||
# The code below has been commented due to slow execution affecting Travis.
|
||||
# >>> solution()
|
||||
# 31875000
|
||||
"""
|
||||
for a in range(300):
|
||||
for b in range(400):
|
||||
|
||||
@@ -21,8 +21,8 @@ def solution():
|
||||
1. a**2 + b**2 = c**2
|
||||
2. a + b + c = 1000
|
||||
|
||||
>>> solution()
|
||||
31875000
|
||||
#>>> solution()
|
||||
#31875000
|
||||
"""
|
||||
return [
|
||||
a * b * c
|
||||
|
||||
@@ -42,8 +42,9 @@ def sum_of_primes(n):
|
||||
def solution(n):
|
||||
"""Returns the sum of all the primes below n.
|
||||
|
||||
>>> solution(2000000)
|
||||
142913828922
|
||||
# The code below has been commented due to slow execution affecting Travis.
|
||||
# >>> solution(2000000)
|
||||
# 142913828922
|
||||
>>> solution(1000)
|
||||
76127
|
||||
>>> solution(5000)
|
||||
|
||||
@@ -31,8 +31,9 @@ def prime_generator():
|
||||
def solution(n):
|
||||
"""Returns the sum of all the primes below n.
|
||||
|
||||
>>> solution(2000000)
|
||||
142913828922
|
||||
# The code below has been commented due to slow execution affecting Travis.
|
||||
# >>> solution(2000000)
|
||||
# 142913828922
|
||||
>>> solution(1000)
|
||||
76127
|
||||
>>> solution(5000)
|
||||
|
||||
@@ -45,8 +45,9 @@ def solution():
|
||||
"""Returns the value of the first triangle number to have over five hundred
|
||||
divisors.
|
||||
|
||||
>>> solution()
|
||||
76576500
|
||||
# The code below has been commented due to slow execution affecting Travis.
|
||||
# >>> solution()
|
||||
# 76576500
|
||||
"""
|
||||
tNum = 1
|
||||
i = 1
|
||||
|
||||
@@ -39,8 +39,9 @@ def solution():
|
||||
"""Returns the value of the first triangle number to have over five hundred
|
||||
divisors.
|
||||
|
||||
>>> solution()
|
||||
76576500
|
||||
# The code below has been commented due to slow execution affecting Travis.
|
||||
# >>> solution()
|
||||
# 76576500
|
||||
"""
|
||||
return next(
|
||||
i for i in triangle_number_generator() if count_divisors(i) > 500
|
||||
|
||||
@@ -30,8 +30,9 @@ def solution(n):
|
||||
n → n/2 (n is even)
|
||||
n → 3n + 1 (n is odd)
|
||||
|
||||
>>> solution(1000000)
|
||||
{'counter': 525, 'largest_number': 837799}
|
||||
# The code below has been commented due to slow execution affecting Travis.
|
||||
# >>> solution(1000000)
|
||||
# {'counter': 525, 'largest_number': 837799}
|
||||
>>> solution(200)
|
||||
{'counter': 125, 'largest_number': 171}
|
||||
>>> solution(5000)
|
||||
|
||||
@@ -47,8 +47,9 @@ def collatz_sequence(n):
|
||||
def solution(n):
|
||||
"""Returns the number under n that generates the longest Collatz sequence.
|
||||
|
||||
>>> solution(1000000)
|
||||
{'counter': 525, 'largest_number': 837799}
|
||||
# The code below has been commented due to slow execution affecting Travis.
|
||||
# >>> solution(1000000)
|
||||
# {'counter': 525, 'largest_number': 837799}
|
||||
>>> solution(200)
|
||||
{'counter': 125, 'largest_number': 171}
|
||||
>>> solution(5000)
|
||||
|
||||
Reference in New Issue
Block a user