Misc fixes across multiple algorithms (#6912)

Source: Snyk code quality
Add scikit-fuzzy to requirements

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
This commit is contained in:
CenTdemeern1
2022-10-15 22:25:38 -07:00
committed by GitHub
parent c94e215c8d
commit 04698538d8
19 changed files with 40 additions and 48 deletions

View File

@ -26,9 +26,7 @@ def solution(n: int = 1000) -> int:
result = 0
for i in range(n):
if i % 3 == 0:
result += i
elif i % 5 == 0:
if i % 3 == 0 or i % 5 == 0:
result += i
return result

View File

@ -34,12 +34,11 @@ def solution():
words = f.readline()
words = [word.strip('"') for word in words.strip("\r\n").split(",")]
words = list(
filter(
lambda word: word in TRIANGULAR_NUMBERS,
(sum(ord(x) - 64 for x in word) for word in words),
)
)
words = [
word
for word in [sum(ord(x) - 64 for x in word) for word in words]
if word in TRIANGULAR_NUMBERS
]
return len(words)

View File

@ -28,8 +28,12 @@ def solution():
with open(triangle) as f:
triangle = f.readlines()
a = (x.rstrip("\r\n").split(" ") for x in triangle)
a = [list(map(int, x)) for x in a]
a = []
for line in triangle:
numbers_from_line = []
for number in line.strip().split(" "):
numbers_from_line.append(int(number))
a.append(numbers_from_line)
for i in range(1, len(a)):
for j in range(len(a[i])):

View File

@ -125,8 +125,9 @@ def solution(roman_numerals_filename: str = "/p089_roman.txt") -> int:
savings = 0
file1 = open(os.path.dirname(__file__) + roman_numerals_filename)
lines = file1.readlines()
with open(os.path.dirname(__file__) + roman_numerals_filename) as file1:
lines = file1.readlines()
for line in lines:
original = line.strip()
num = parse_roman_numerals(original)