From 6f439de6c377565b6c2b3ab2bc488f2183c25b0a Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:00:22 +0300 Subject: [PATCH 01/19] Enable ruff ARG001 rule --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2e7da519da8b..a69ab7aa6437 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [tool.ruff] 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 "B905", # `zip()` without an explicit `strict=` parameter -- FIX ME "DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed -- FIX ME From 1466d762e765f99a0d93ce1a5c5996497933114b Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:05:45 +0300 Subject: [PATCH 02/19] Fix dynamic_programming/combination_sum_iv.py --- dynamic_programming/combination_sum_iv.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dynamic_programming/combination_sum_iv.py b/dynamic_programming/combination_sum_iv.py index b2aeb0824f64..2b8d92acf97a 100644 --- a/dynamic_programming/combination_sum_iv.py +++ b/dynamic_programming/combination_sum_iv.py @@ -22,12 +22,12 @@ """ -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 of possible combination in exponential Time Complexity. - >>> combination_sum_iv(3, [1,2,5], 5) + >>> combination_sum_iv([1,2,5], 5) 9 """ @@ -41,13 +41,13 @@ def count_of_possible_combinations(target: int) -> int: 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 of possible combination in O(N^2) Time Complexity as we are using Dynamic programming array here. - >>> combination_sum_iv_dp_array(3, [1,2,5], 5) + >>> combination_sum_iv_dp_array([1,2,5], 5) 9 """ From 875c4aa50e79e6b449d755c2060bb0f023ab9b18 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:27:44 +0300 Subject: [PATCH 03/19] Fix machine_learning/frequent_pattern_growth.py --- machine_learning/frequent_pattern_growth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine_learning/frequent_pattern_growth.py b/machine_learning/frequent_pattern_growth.py index 205d598464a1..82cf0d010951 100644 --- a/machine_learning/frequent_pattern_growth.py +++ b/machine_learning/frequent_pattern_growth.py @@ -239,7 +239,7 @@ def ascend_tree(leaf_node: TreeNode, prefix_path: list[str]) -> None: 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. @@ -276,7 +276,7 @@ def find_prefix_path(base_pat: frozenset, tree_node: TreeNode | None) -> dict: def mine_tree( - in_tree: TreeNode, + in_tree: TreeNode, # noqa: ARG001 header_table: dict, min_sup: int, pre_fix: set, From c8a60c9d298bcff37fc2c6d74e6b7149980bd3b0 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:28:35 +0300 Subject: [PATCH 04/19] Fix other/davis_putnam_logemann_loveland.py --- other/davis_putnam_logemann_loveland.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/davis_putnam_logemann_loveland.py b/other/davis_putnam_logemann_loveland.py index f5fb103ba528..e766374be0cf 100644 --- a/other/davis_putnam_logemann_loveland.py +++ b/other/davis_putnam_logemann_loveland.py @@ -226,7 +226,7 @@ def find_pure_symbols( 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]]: """ Returns the unit symbols and their values to satisfy clause. From 5cab0b002aea7651492aa3ca998975f94008c8de Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:29:19 +0300 Subject: [PATCH 05/19] Fix other/password.py --- other/password.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/other/password.py b/other/password.py index 1ce0d52316e6..e9c527a463ad 100644 --- a/other/password.py +++ b/other/password.py @@ -51,16 +51,19 @@ def random(chars_incl: str, i: int) -> str: return "".join(secrets.choice(chars_incl) for _ in range(i)) -def random_number(chars_incl, i): - pass # Put your code here... +# Put your code here... +# def random_number(chars_incl, i): +# pass -def random_letters(chars_incl, i): - pass # Put your code here... +# Put your code here... +# def random_letters(chars_incl, i): +# pass -def random_characters(chars_incl, i): - pass # Put your code here... +# Put your code here... +# def random_characters(chars_incl, i): +# pass def is_strong_password(password: str, min_length: int = 8) -> bool: From 75aab9139e8d743d830551a4548f1e41036b00a7 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:30:16 +0300 Subject: [PATCH 06/19] Fix --- other/password.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/other/password.py b/other/password.py index e9c527a463ad..7684e989180a 100644 --- a/other/password.py +++ b/other/password.py @@ -51,19 +51,16 @@ def random(chars_incl: str, i: int) -> str: return "".join(secrets.choice(chars_incl) for _ in range(i)) -# Put your code here... # def random_number(chars_incl, i): -# pass +# pass # Put your code here... -# Put your code here... # def random_letters(chars_incl, i): -# pass +# pass # Put your code here... -# Put your code here... # def random_characters(chars_incl, i): -# pass +# pass # Put your code here... def is_strong_password(password: str, min_length: int = 8) -> bool: From c128e626adbb8d3370cc6b7fd5c7f07009c76f21 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:32:02 +0000 Subject: [PATCH 07/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/davis_putnam_logemann_loveland.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/other/davis_putnam_logemann_loveland.py b/other/davis_putnam_logemann_loveland.py index e766374be0cf..5535efdd8b50 100644 --- a/other/davis_putnam_logemann_loveland.py +++ b/other/davis_putnam_logemann_loveland.py @@ -226,7 +226,8 @@ def find_pure_symbols( def find_unit_clauses( - clauses: list[Clause], model: dict[str, bool | None] # noqa: ARG001 + clauses: list[Clause], + model: dict[str, bool | None], # noqa: ARG001 ) -> tuple[list[str], dict[str, bool | None]]: """ Returns the unit symbols and their values to satisfy clause. From 45114f827b9209a2a7419b999a0ccb8c46816993 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:32:48 +0300 Subject: [PATCH 08/19] Fix physics/n_body_simulation.py --- physics/n_body_simulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/n_body_simulation.py b/physics/n_body_simulation.py index ec008784ba62..116ebf46f508 100644 --- a/physics/n_body_simulation.py +++ b/physics/n_body_simulation.py @@ -240,7 +240,7 @@ def plot( ax.add_patch(patch) # 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) return patches From 41c328cdfe65961897ee6dd7bef1b80db4430d39 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:38:17 +0300 Subject: [PATCH 09/19] Fix project_euler/problem_145/sol1.py --- project_euler/problem_145/sol1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_145/sol1.py b/project_euler/problem_145/sol1.py index 71b851178fdb..8a7b78635b2e 100644 --- a/project_euler/problem_145/sol1.py +++ b/project_euler/problem_145/sol1.py @@ -109,7 +109,7 @@ def reversible_numbers( if (length - 1) % 4 == 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: From 96897955d9592bdf141b01b353b8613e67b85921 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:42:24 +0300 Subject: [PATCH 10/19] Fix project_euler/problem_174/sol1.py --- project_euler/problem_174/sol1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_174/sol1.py b/project_euler/problem_174/sol1.py index cbc0df5a9d65..81caa44804df 100644 --- a/project_euler/problem_174/sol1.py +++ b/project_euler/problem_174/sol1.py @@ -45,7 +45,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): 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__": From 10b03824b639a68028d1ac60b5198bb9a2da147b Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:45:03 +0300 Subject: [PATCH 11/19] Fix scheduling/highest_response_ratio_next.py --- scheduling/highest_response_ratio_next.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduling/highest_response_ratio_next.py b/scheduling/highest_response_ratio_next.py index 057bd64cc729..ca549d094c51 100644 --- a/scheduling/highest_response_ratio_next.py +++ b/scheduling/highest_response_ratio_next.py @@ -74,7 +74,7 @@ def calculate_turn_around_time( def calculate_waiting_time( - process_name: list, turn_around_time: list, burst_time: list, no_of_process: int + process_name: list, turn_around_time: list, burst_time: list, no_of_process: int # noqa ARG001 ) -> list: """ Calculate the waiting time of each processes. From 22eaaa5645155e9a37fccaa7019dd9075f83b411 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:45:28 +0000 Subject: [PATCH 12/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scheduling/highest_response_ratio_next.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scheduling/highest_response_ratio_next.py b/scheduling/highest_response_ratio_next.py index ca549d094c51..506afb810445 100644 --- a/scheduling/highest_response_ratio_next.py +++ b/scheduling/highest_response_ratio_next.py @@ -74,7 +74,10 @@ def calculate_turn_around_time( def calculate_waiting_time( - process_name: list, turn_around_time: list, burst_time: list, no_of_process: int # noqa ARG001 + process_name: list, + turn_around_time: list, + burst_time: list, + no_of_process: int, # noqa ARG001 ) -> list: """ Calculate the waiting time of each processes. From e79a480521d659197d4afa10fc22dca7e5e65e0d Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:46:50 +0300 Subject: [PATCH 13/19] Fix --- scheduling/highest_response_ratio_next.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scheduling/highest_response_ratio_next.py b/scheduling/highest_response_ratio_next.py index 506afb810445..045f702d34ce 100644 --- a/scheduling/highest_response_ratio_next.py +++ b/scheduling/highest_response_ratio_next.py @@ -74,10 +74,10 @@ def calculate_turn_around_time( def calculate_waiting_time( - process_name: list, + process_name: list, # noqa ARG001 turn_around_time: list, burst_time: list, - no_of_process: int, # noqa ARG001 + no_of_process: int, ) -> list: """ Calculate the waiting time of each processes. From cbe4cc50972bdd33d5bc61c92b48a52fd3ddaf0d Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:49:10 +0300 Subject: [PATCH 14/19] Fix --- scheduling/highest_response_ratio_next.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduling/highest_response_ratio_next.py b/scheduling/highest_response_ratio_next.py index 045f702d34ce..85cc7857fa41 100644 --- a/scheduling/highest_response_ratio_next.py +++ b/scheduling/highest_response_ratio_next.py @@ -74,7 +74,7 @@ def calculate_turn_around_time( def calculate_waiting_time( - process_name: list, # noqa ARG001 + process_name: list, # noqa: ARG001 turn_around_time: list, burst_time: list, no_of_process: int, From 03b747f2aa5cb4a2f9f05710ea7212dac628899a Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:51:00 +0300 Subject: [PATCH 15/19] Fix scheduling/job_sequencing_with_deadline.py --- scheduling/job_sequencing_with_deadline.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scheduling/job_sequencing_with_deadline.py b/scheduling/job_sequencing_with_deadline.py index 7b23c0b3575f..13946948492f 100644 --- a/scheduling/job_sequencing_with_deadline.py +++ b/scheduling/job_sequencing_with_deadline.py @@ -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 Args: - num_jobs [int]: Number of jobs jobs [list]: A list of tuples of (job_id, deadline, profit) Returns: @@ -11,10 +10,10 @@ def job_sequencing_with_deadlines(num_jobs: int, jobs: list) -> list: in a given time frame Examples: - >>> job_sequencing_with_deadlines(4, + >>> job_sequencing_with_deadlines( ... [(1, 4, 20), (2, 1, 10), (3, 1, 40), (4, 1, 30)]) [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)]) [2, 127] """ From 781ebe6afb697d51fce20e8df30e4ca2866e7910 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:52:23 +0300 Subject: [PATCH 16/19] Fix scheduling/job_sequencing_with_deadline.py --- web_programming/nasa_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/nasa_data.py b/web_programming/nasa_data.py index c0a2c4fdd1a7..81125e0a4f05 100644 --- a/web_programming/nasa_data.py +++ b/web_programming/nasa_data.py @@ -3,7 +3,7 @@ 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 your API Key from: https://api.nasa.gov/ From 097a23f28b077703d6e086a5edef516dd64974c4 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:54:56 +0300 Subject: [PATCH 17/19] Fix --- dynamic_programming/combination_sum_iv.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dynamic_programming/combination_sum_iv.py b/dynamic_programming/combination_sum_iv.py index 2b8d92acf97a..4526729b70b7 100644 --- a/dynamic_programming/combination_sum_iv.py +++ b/dynamic_programming/combination_sum_iv.py @@ -96,7 +96,6 @@ def combination_sum_iv_bottom_up(n: int, array: list[int], target: int) -> int: import doctest doctest.testmod() - n = 3 target = 5 array = [1, 2, 5] - print(combination_sum_iv(n, array, target)) + print(combination_sum_iv(array, target)) From 2485e7006b4d713d3e1f41d8f02efd0b5e8a89a4 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 12 Mar 2024 19:58:33 +0300 Subject: [PATCH 18/19] Fix --- project_euler/problem_174/sol1.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project_euler/problem_174/sol1.py b/project_euler/problem_174/sol1.py index 81caa44804df..33c1b158adbb 100644 --- a/project_euler/problem_174/sol1.py +++ b/project_euler/problem_174/sol1.py @@ -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. >>> solution(1000,5) + 222 + >>> solution(1000,10) 249 >>> solution(10000,10) 2383 From 22122f4a4159c5420dbbc65da0a99027cf1f1375 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 20 Mar 2024 14:59:29 +0100 Subject: [PATCH 19/19] Update password.py --- other/password.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/other/password.py b/other/password.py index 7684e989180a..dff1316c049c 100644 --- a/other/password.py +++ b/other/password.py @@ -51,18 +51,6 @@ def random(chars_incl: str, i: int) -> str: 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: """ This will check whether a given password is strong or not. The password must be at