mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Tighten up psf/black and flake8 (#2024)
* Tighten up psf/black and flake8
* Fix some tests
* Fix some E741
* Fix some E741
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@@ -48,7 +48,7 @@ def solution(n):
|
||||
"""
|
||||
try:
|
||||
n = int(n)
|
||||
except (TypeError, ValueError) as e:
|
||||
except (TypeError, ValueError):
|
||||
raise TypeError("Parameter n must be int or passive of cast to int.")
|
||||
if n <= 0:
|
||||
raise ValueError("Parameter n must be greater or equal to one.")
|
||||
|
||||
@@ -50,7 +50,7 @@ def solution(n):
|
||||
"""
|
||||
try:
|
||||
n = int(n)
|
||||
except (TypeError, ValueError) as e:
|
||||
except (TypeError, ValueError):
|
||||
raise TypeError("Parameter n must be int or passive of cast to int.")
|
||||
if n <= 0:
|
||||
raise ValueError("Parameter n must be greater or equal to one.")
|
||||
|
||||
@@ -37,7 +37,7 @@ def solution(n):
|
||||
"""
|
||||
try:
|
||||
n = int(n)
|
||||
except (TypeError, ValueError) as e:
|
||||
except (TypeError, ValueError):
|
||||
raise TypeError("Parameter n must be int or passive of cast to int.")
|
||||
if n <= 0:
|
||||
raise ValueError("Parameter n must be greater or equal to one.")
|
||||
|
||||
@@ -41,7 +41,7 @@ def solution(n):
|
||||
"""
|
||||
try:
|
||||
n = int(n)
|
||||
except (TypeError, ValueError) as e:
|
||||
except (TypeError, ValueError):
|
||||
raise TypeError("Parameter n must be int or passive of cast to int.")
|
||||
if n <= 0:
|
||||
raise ValueError("Parameter n must be greater or equal to one.")
|
||||
|
||||
@@ -50,7 +50,7 @@ def solution(n):
|
||||
"""
|
||||
try:
|
||||
n = int(n)
|
||||
except (TypeError, ValueError) as e:
|
||||
except (TypeError, ValueError):
|
||||
raise TypeError("Parameter n must be int or passive of cast to int.")
|
||||
if n <= 0:
|
||||
raise ValueError("Parameter n must be greater or equal to one.")
|
||||
|
||||
@@ -53,7 +53,7 @@ N = """73167176531330624919225119674426574742355349194934\
|
||||
def solution(n):
|
||||
"""Find the thirteen adjacent digits in the 1000-digit number n that have
|
||||
the greatest product and returns it.
|
||||
|
||||
|
||||
>>> solution(N)
|
||||
23514624000
|
||||
"""
|
||||
|
||||
@@ -56,7 +56,7 @@ N = (
|
||||
def solution(n):
|
||||
"""Find the thirteen adjacent digits in the 1000-digit number n that have
|
||||
the greatest product and returns it.
|
||||
|
||||
|
||||
>>> solution(N)
|
||||
23514624000
|
||||
"""
|
||||
|
||||
@@ -60,7 +60,7 @@ def streval(s: str) -> int:
|
||||
def solution(n: str) -> int:
|
||||
"""Find the thirteen adjacent digits in the 1000-digit number n that have
|
||||
the greatest product and returns it.
|
||||
|
||||
|
||||
>>> solution(N)
|
||||
23514624000
|
||||
"""
|
||||
|
||||
@@ -34,7 +34,7 @@ def solution():
|
||||
70600674
|
||||
"""
|
||||
with open(os.path.dirname(__file__) + "/grid.txt") as f:
|
||||
l = []
|
||||
l = [] # noqa: E741
|
||||
for i in range(20):
|
||||
l.append([int(x) for x in f.readline().split()])
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ What is the sum of the digits of the number 2^1000?
|
||||
|
||||
def solution(power):
|
||||
"""Returns the sum of the digits of the number 2^power.
|
||||
|
||||
|
||||
>>> solution(1000)
|
||||
1366
|
||||
>>> solution(50)
|
||||
|
||||
@@ -40,7 +40,7 @@ def solution(n):
|
||||
"""Returns the sum of all semidivisible numbers not exceeding n."""
|
||||
semidivisible = []
|
||||
for x in range(n):
|
||||
l = [i for i in input().split()]
|
||||
l = [i for i in input().split()] # noqa: E741
|
||||
c2 = 1
|
||||
while 1:
|
||||
if len(fib(l[0], l[1], c2)) < int(l[2]):
|
||||
|
||||
@@ -10,7 +10,7 @@ As 1 = 1^4 is not a sum it is not included.
|
||||
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
|
||||
|
||||
Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
|
||||
|
||||
|
||||
(9^5)=59,049
|
||||
59049*7=4,13,343 (which is only 6 digit number )
|
||||
So, number greater than 9,99,999 are rejected
|
||||
|
||||
@@ -30,7 +30,7 @@ Example:
|
||||
|
||||
|
||||
def solution(pence: int) -> int:
|
||||
"""Returns the number of different ways to make X pence using any number of coins.
|
||||
"""Returns the number of different ways to make X pence using any number of coins.
|
||||
The solution is based on dynamic programming paradigm in a bottom-up fashion.
|
||||
|
||||
>>> solution(500)
|
||||
|
||||
@@ -28,7 +28,7 @@ def next_term(a_i, k, i, n):
|
||||
is cached to greatly speed up the computation.
|
||||
|
||||
Arguments:
|
||||
a_i -- array of digits starting from the one's place that represent
|
||||
a_i -- array of digits starting from the one's place that represent
|
||||
the i-th term in the sequence
|
||||
k -- k when terms are written in the from a(i) = b*10^k + c.
|
||||
Term are calulcated until c > 10^k or the n-th term is reached.
|
||||
|
||||
Reference in New Issue
Block a user