mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Make some ruff fixes (#8154)
* Make some ruff fixes * Undo manual fix * Undo manual fix * Updates from ruff=0.0.251
This commit is contained in:
@ -34,7 +34,7 @@ def all_construct(target: str, word_bank: list[str] | None = None) -> list[list[
|
||||
# slice condition
|
||||
if target[i : i + len(word)] == word:
|
||||
new_combinations: list[list[str]] = [
|
||||
[word] + way for way in table[i]
|
||||
[word, *way] for way in table[i]
|
||||
]
|
||||
# adds the word to every combination the current position holds
|
||||
# now,push that combination to the table[i+len(word)]
|
||||
|
@ -49,7 +49,7 @@ def fizz_buzz(number: int, iterations: int) -> str:
|
||||
out += "Fizz"
|
||||
if number % 5 == 0:
|
||||
out += "Buzz"
|
||||
if not number % 3 == 0 and not number % 5 == 0:
|
||||
if 0 not in (number % 3, number % 5):
|
||||
out += str(number)
|
||||
|
||||
# print(out)
|
||||
|
@ -42,20 +42,14 @@ def longest_common_subsequence(x: str, y: str):
|
||||
|
||||
for i in range(1, m + 1):
|
||||
for j in range(1, n + 1):
|
||||
if x[i - 1] == y[j - 1]:
|
||||
match = 1
|
||||
else:
|
||||
match = 0
|
||||
match = 1 if x[i - 1] == y[j - 1] else 0
|
||||
|
||||
l[i][j] = max(l[i - 1][j], l[i][j - 1], l[i - 1][j - 1] + match)
|
||||
|
||||
seq = ""
|
||||
i, j = m, n
|
||||
while i > 0 and j > 0:
|
||||
if x[i - 1] == y[j - 1]:
|
||||
match = 1
|
||||
else:
|
||||
match = 0
|
||||
match = 1 if x[i - 1] == y[j - 1] else 0
|
||||
|
||||
if l[i][j] == l[i - 1][j - 1] + match:
|
||||
if match == 1:
|
||||
|
@ -48,7 +48,7 @@ def longest_subsequence(array: list[int]) -> list[int]: # This function is recu
|
||||
i += 1
|
||||
|
||||
temp_array = [element for element in array[1:] if element >= pivot]
|
||||
temp_array = [pivot] + longest_subsequence(temp_array)
|
||||
temp_array = [pivot, *longest_subsequence(temp_array)]
|
||||
if len(temp_array) > len(longest_subseq):
|
||||
return temp_array
|
||||
else:
|
||||
|
Reference in New Issue
Block a user