mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Enable ruff ARG001 rule (#11321)
* Enable ruff ARG001 rule * Fix dynamic_programming/combination_sum_iv.py * Fix machine_learning/frequent_pattern_growth.py * Fix other/davis_putnam_logemann_loveland.py * Fix other/password.py * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix physics/n_body_simulation.py * Fix project_euler/problem_145/sol1.py * Fix project_euler/problem_174/sol1.py * Fix scheduling/highest_response_ratio_next.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Fix * Fix scheduling/job_sequencing_with_deadline.py * Fix scheduling/job_sequencing_with_deadline.py * Fix * Fix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
8faf823e83
commit
a936e94704
|
@ -22,12 +22,12 @@ of chosen elements is “tar”. For every element, we have two choices
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def combination_sum_iv(n: int, array: list[int], target: int) -> int:
|
def combination_sum_iv(array: list[int], target: int) -> int:
|
||||||
"""
|
"""
|
||||||
Function checks the all possible combinations, and returns the count
|
Function checks the all possible combinations, and returns the count
|
||||||
of possible combination in exponential Time Complexity.
|
of possible combination in exponential Time Complexity.
|
||||||
|
|
||||||
>>> combination_sum_iv(3, [1,2,5], 5)
|
>>> combination_sum_iv([1,2,5], 5)
|
||||||
9
|
9
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@ def combination_sum_iv(n: int, array: list[int], target: int) -> int:
|
||||||
return count_of_possible_combinations(target)
|
return count_of_possible_combinations(target)
|
||||||
|
|
||||||
|
|
||||||
def combination_sum_iv_dp_array(n: int, array: list[int], target: int) -> int:
|
def combination_sum_iv_dp_array(array: list[int], target: int) -> int:
|
||||||
"""
|
"""
|
||||||
Function checks the all possible combinations, and returns the count
|
Function checks the all possible combinations, and returns the count
|
||||||
of possible combination in O(N^2) Time Complexity as we are using Dynamic
|
of possible combination in O(N^2) Time Complexity as we are using Dynamic
|
||||||
programming array here.
|
programming array here.
|
||||||
|
|
||||||
>>> combination_sum_iv_dp_array(3, [1,2,5], 5)
|
>>> combination_sum_iv_dp_array([1,2,5], 5)
|
||||||
9
|
9
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -96,7 +96,6 @@ if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
n = 3
|
|
||||||
target = 5
|
target = 5
|
||||||
array = [1, 2, 5]
|
array = [1, 2, 5]
|
||||||
print(combination_sum_iv(n, array, target))
|
print(combination_sum_iv(array, target))
|
||||||
|
|
|
@ -240,7 +240,7 @@ def ascend_tree(leaf_node: TreeNode, prefix_path: list[str]) -> None:
|
||||||
ascend_tree(leaf_node.parent, prefix_path)
|
ascend_tree(leaf_node.parent, prefix_path)
|
||||||
|
|
||||||
|
|
||||||
def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict:
|
def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict: # noqa: ARG001
|
||||||
"""
|
"""
|
||||||
Find the conditional pattern base for a given base pattern.
|
Find the conditional pattern base for a given base pattern.
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict:
|
||||||
|
|
||||||
|
|
||||||
def mine_tree(
|
def mine_tree(
|
||||||
in_tree: TreeNode,
|
in_tree: TreeNode, # noqa: ARG001
|
||||||
header_table: dict,
|
header_table: dict,
|
||||||
min_sup: int,
|
min_sup: int,
|
||||||
pre_fix: set,
|
pre_fix: set,
|
||||||
|
|
|
@ -227,7 +227,8 @@ def find_pure_symbols(
|
||||||
|
|
||||||
|
|
||||||
def find_unit_clauses(
|
def find_unit_clauses(
|
||||||
clauses: list[Clause], model: dict[str, bool | None]
|
clauses: list[Clause],
|
||||||
|
model: dict[str, bool | None], # noqa: ARG001
|
||||||
) -> tuple[list[str], dict[str, bool | None]]:
|
) -> tuple[list[str], dict[str, bool | None]]:
|
||||||
"""
|
"""
|
||||||
Returns the unit symbols and their values to satisfy clause.
|
Returns the unit symbols and their values to satisfy clause.
|
||||||
|
|
|
@ -51,18 +51,6 @@ def random(chars_incl: str, i: int) -> str:
|
||||||
return "".join(secrets.choice(chars_incl) for _ in range(i))
|
return "".join(secrets.choice(chars_incl) for _ in range(i))
|
||||||
|
|
||||||
|
|
||||||
def random_number(chars_incl, i):
|
|
||||||
pass # Put your code here...
|
|
||||||
|
|
||||||
|
|
||||||
def random_letters(chars_incl, i):
|
|
||||||
pass # Put your code here...
|
|
||||||
|
|
||||||
|
|
||||||
def random_characters(chars_incl, i):
|
|
||||||
pass # Put your code here...
|
|
||||||
|
|
||||||
|
|
||||||
def is_strong_password(password: str, min_length: int = 8) -> bool:
|
def is_strong_password(password: str, min_length: int = 8) -> bool:
|
||||||
"""
|
"""
|
||||||
This will check whether a given password is strong or not. The password must be at
|
This will check whether a given password is strong or not. The password must be at
|
||||||
|
|
|
@ -239,7 +239,7 @@ def plot(
|
||||||
ax.add_patch(patch)
|
ax.add_patch(patch)
|
||||||
|
|
||||||
# Function called at each step of the animation
|
# Function called at each step of the animation
|
||||||
def update(frame: int) -> list[plt.Circle]:
|
def update(frame: int) -> list[plt.Circle]: # noqa: ARG001
|
||||||
update_step(body_system, DELTA_TIME, patches)
|
update_step(body_system, DELTA_TIME, patches)
|
||||||
return patches
|
return patches
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ def reversible_numbers(
|
||||||
if (length - 1) % 4 == 0:
|
if (length - 1) % 4 == 0:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
return slow_reversible_numbers(length, 0, [0] * length, length)
|
return slow_reversible_numbers(remaining_length, remainder, digits, length)
|
||||||
|
|
||||||
|
|
||||||
def solution(max_power: int = 9) -> int:
|
def solution(max_power: int = 9) -> int:
|
||||||
|
|
|
@ -26,6 +26,8 @@ def solution(t_limit: int = 1000000, n_limit: int = 10) -> int:
|
||||||
Return the sum of N(n) for 1 <= n <= n_limit.
|
Return the sum of N(n) for 1 <= n <= n_limit.
|
||||||
|
|
||||||
>>> solution(1000,5)
|
>>> solution(1000,5)
|
||||||
|
222
|
||||||
|
>>> solution(1000,10)
|
||||||
249
|
249
|
||||||
>>> solution(10000,10)
|
>>> solution(10000,10)
|
||||||
2383
|
2383
|
||||||
|
@ -45,7 +47,7 @@ def solution(t_limit: int = 1000000, n_limit: int = 10) -> int:
|
||||||
for hole_width in range(hole_width_lower_bound, outer_width - 1, 2):
|
for hole_width in range(hole_width_lower_bound, outer_width - 1, 2):
|
||||||
count[outer_width * outer_width - hole_width * hole_width] += 1
|
count[outer_width * outer_width - hole_width * hole_width] += 1
|
||||||
|
|
||||||
return sum(1 for n in count.values() if 1 <= n <= 10)
|
return sum(1 for n in count.values() if 1 <= n <= n_limit)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
lint.ignore = [ # `ruff rule S101` for a description of that rule
|
lint.ignore = [ # `ruff rule S101` for a description of that rule
|
||||||
"ARG001", # Unused function argument `amount` -- FIX ME?
|
|
||||||
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME
|
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME
|
||||||
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME
|
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME
|
||||||
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed -- FIX ME
|
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed -- FIX ME
|
||||||
|
|
|
@ -75,7 +75,10 @@ def calculate_turn_around_time(
|
||||||
|
|
||||||
|
|
||||||
def calculate_waiting_time(
|
def calculate_waiting_time(
|
||||||
process_name: list, turn_around_time: list, burst_time: list, no_of_process: int
|
process_name: list, # noqa: ARG001
|
||||||
|
turn_around_time: list,
|
||||||
|
burst_time: list,
|
||||||
|
no_of_process: int,
|
||||||
) -> list:
|
) -> list:
|
||||||
"""
|
"""
|
||||||
Calculate the waiting time of each processes.
|
Calculate the waiting time of each processes.
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
def job_sequencing_with_deadlines(num_jobs: int, jobs: list) -> list:
|
def job_sequencing_with_deadlines(jobs: list) -> list:
|
||||||
"""
|
"""
|
||||||
Function to find the maximum profit by doing jobs in a given time frame
|
Function to find the maximum profit by doing jobs in a given time frame
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
num_jobs [int]: Number of jobs
|
|
||||||
jobs [list]: A list of tuples of (job_id, deadline, profit)
|
jobs [list]: A list of tuples of (job_id, deadline, profit)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -11,10 +10,10 @@ def job_sequencing_with_deadlines(num_jobs: int, jobs: list) -> list:
|
||||||
in a given time frame
|
in a given time frame
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
>>> job_sequencing_with_deadlines(4,
|
>>> job_sequencing_with_deadlines(
|
||||||
... [(1, 4, 20), (2, 1, 10), (3, 1, 40), (4, 1, 30)])
|
... [(1, 4, 20), (2, 1, 10), (3, 1, 40), (4, 1, 30)])
|
||||||
[2, 60]
|
[2, 60]
|
||||||
>>> job_sequencing_with_deadlines(5,
|
>>> job_sequencing_with_deadlines(
|
||||||
... [(1, 2, 100), (2, 1, 19), (3, 2, 27), (4, 1, 25), (5, 1, 15)])
|
... [(1, 2, 100), (2, 1, 19), (3, 2, 27), (4, 1, 25), (5, 1, 15)])
|
||||||
[2, 127]
|
[2, 127]
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -3,7 +3,7 @@ import shutil
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def get_apod_data(api_key: str, download: bool = False, path: str = ".") -> dict:
|
def get_apod_data(api_key: str) -> dict:
|
||||||
"""
|
"""
|
||||||
Get the APOD(Astronomical Picture of the day) data
|
Get the APOD(Astronomical Picture of the day) data
|
||||||
Get your API Key from: https://api.nasa.gov/
|
Get your API Key from: https://api.nasa.gov/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user