From 95675ea482323a00adacf224b07f53a2bb3f5e8f Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 10 Mar 2026 13:39:44 +0300 Subject: [PATCH 01/16] Add function to calculate pyramid height --- Week03/pyramid_senkiv_vladyslav | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Week03/pyramid_senkiv_vladyslav diff --git a/Week03/pyramid_senkiv_vladyslav b/Week03/pyramid_senkiv_vladyslav new file mode 100644 index 00000000..f9aaddd5 --- /dev/null +++ b/Week03/pyramid_senkiv_vladyslav @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + i = 1 + + while number_of_blocks >= i: + number_of_blocks = number_of_blocks - i + height += 1 + i += 1 + + return height From 7446839b70eca5b467d190bc8feb597ebb5b21dc Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 10 Mar 2026 13:40:14 +0300 Subject: [PATCH 02/16] Rename pyramid_senkiv_vladyslav to pyramid_senkiv_vladyslav.py --- Week03/{pyramid_senkiv_vladyslav => pyramid_senkiv_vladyslav.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Week03/{pyramid_senkiv_vladyslav => pyramid_senkiv_vladyslav.py} (100%) diff --git a/Week03/pyramid_senkiv_vladyslav b/Week03/pyramid_senkiv_vladyslav.py similarity index 100% rename from Week03/pyramid_senkiv_vladyslav rename to Week03/pyramid_senkiv_vladyslav.py From d4283e9b6952715d432b1c6038b750745e890dd7 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Sat, 28 Mar 2026 15:19:04 +0300 Subject: [PATCH 03/16] Rename pyramid_senkiv_vladyslav.py to pyramid_vladyslav_senkiv.py --- .../{pyramid_senkiv_vladyslav.py => pyramid_vladyslav_senkiv.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Week03/{pyramid_senkiv_vladyslav.py => pyramid_vladyslav_senkiv.py} (100%) diff --git a/Week03/pyramid_senkiv_vladyslav.py b/Week03/pyramid_vladyslav_senkiv.py similarity index 100% rename from Week03/pyramid_senkiv_vladyslav.py rename to Week03/pyramid_vladyslav_senkiv.py From cab235348fbb49a315a7ea2ced6de94654e9d1b7 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Sun, 5 Apr 2026 16:03:42 +0300 Subject: [PATCH 04/16] add sequences_vladyslav_senkiv.py Removed docstring comments from three functions. --- Week03/sequences_vladyslav_senkiv.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Week03/sequences_vladyslav_senkiv.py diff --git a/Week03/sequences_vladyslav_senkiv.py b/Week03/sequences_vladyslav_senkiv.py new file mode 100644 index 00000000..7241c055 --- /dev/null +++ b/Week03/sequences_vladyslav_senkiv.py @@ -0,0 +1,17 @@ +def remove_duplicates(seq: list) -> list: + result = [] + for item in seq: + if item not in result: + result.append(item) + return result + + +def list_counts(seq: list) -> dict: + counts = {} + for item in seq: + counts[item] = counts.get(item, 0) + 1 + return counts + + +def reverse_dict(d: dict) -> dict: + return {value: key for key, value in d.items()} From 2914844c5d063d3af04cc44825038f9bbab385ab Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Sun, 5 Apr 2026 16:09:25 +0300 Subject: [PATCH 05/16] Create decorators_vladyslav_senkiv.py --- Week04/decorators_vladyslav_senkiv.py | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Week04/decorators_vladyslav_senkiv.py diff --git a/Week04/decorators_vladyslav_senkiv.py b/Week04/decorators_vladyslav_senkiv.py new file mode 100644 index 00000000..f1d5e232 --- /dev/null +++ b/Week04/decorators_vladyslav_senkiv.py @@ -0,0 +1,28 @@ +from functools import wraps +from time import perf_counter +import tracemalloc + + + +def performance(func): + + @wraps(func) + def wrapper(*args, **kwargs): + wrapper.counter += 1 + + tracemalloc.start() + start = perf_counter() + try: + return func(*args, **kwargs) + finally: + elapsed = perf_counter() - start + current, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + + wrapper.total_time += elapsed + wrapper.total_mem += peak + + wrapper.counter = 0 + wrapper.total_time = 0.0 + wrapper.total_mem = 0 + return wrapper From a342200d6276024874ed129d7292a2708eeea249 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Sun, 5 Apr 2026 16:11:47 +0300 Subject: [PATCH 06/16] Create functions_vladyslav_senkiv.py --- Week04/functions_vladyslav_senkiv.py | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Week04/functions_vladyslav_senkiv.py diff --git a/Week04/functions_vladyslav_senkiv.py b/Week04/functions_vladyslav_senkiv.py new file mode 100644 index 00000000..be7eca34 --- /dev/null +++ b/Week04/functions_vladyslav_senkiv.py @@ -0,0 +1,41 @@ +import inspect +from typing import Dict, Tuple + + +custom_power = lambda x=0, /, e=1: x**e + + +def custom_equation( + x: int = 0, + y: int = 0, + /, + a: int = 1, + b: int = 1, + *, + c: int = 1, +) -> float: + """Calculate a custom equation. + + :param x: First base value. + :param y: Second base value. + :param a: Exponent for x. + :param b: Exponent for y. + :param c: Divisor value. + :returns: The result of (x**a + y**b) / c. + """ + return float((x**a + y**b) / c) + + +def fn_w_counter() -> Tuple[int, Dict[str, int]]: + """Count total calls and calls grouped by caller module name.""" + if not hasattr(fn_w_counter, "total_calls"): + fn_w_counter.total_calls = 0 + fn_w_counter.caller_counts = {} + + caller_frame = inspect.currentframe().f_back + caller_name = caller_frame.f_globals.get("__name__", "__main__") + + fn_w_counter.total_calls += 1 + fn_w_counter.caller_counts[caller_name] = fn_w_counter.caller_counts.get(caller_name, 0) + 1 + + return fn_w_counter.total_calls, dict(fn_w_counter.caller_counts) From 4ee7ef07541c8191e4fc91bdf917fe8cc9a27462 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Sun, 5 Apr 2026 16:13:35 +0300 Subject: [PATCH 07/16] Create awaitme_vladyslav_senkiv.py --- Week05/awaitme_vladyslav_senkiv.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Week05/awaitme_vladyslav_senkiv.py diff --git a/Week05/awaitme_vladyslav_senkiv.py b/Week05/awaitme_vladyslav_senkiv.py new file mode 100644 index 00000000..76d2e5d2 --- /dev/null +++ b/Week05/awaitme_vladyslav_senkiv.py @@ -0,0 +1,14 @@ +import inspect +from functools import wraps + + + +def awaitme(func): + @wraps(func) + async def wrapper(*args, **kwargs): + result = func(*args, **kwargs) + if inspect.isawaitable(result): + return await result + return result + + return wrapper From 293ce8e2430bcfd208013a84c0f8671bf3e0176c Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Sun, 5 Apr 2026 16:15:57 +0300 Subject: [PATCH 08/16] Create timer_vladyslav_senkiv.py --- Week06/timer_vladyslav_senkiv.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Week06/timer_vladyslav_senkiv.py diff --git a/Week06/timer_vladyslav_senkiv.py b/Week06/timer_vladyslav_senkiv.py new file mode 100644 index 00000000..76b8354d --- /dev/null +++ b/Week06/timer_vladyslav_senkiv.py @@ -0,0 +1,15 @@ +from time import perf_counter + +class Timer: + + def __init__(self): + self.start_time = None + self.end_time = None + + def __enter__(self): + self.start_time = perf_counter() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.end_time = perf_counter() + return False From 6efe4a96843ddfee8b14b85a300acae36db5a446 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Mon, 20 Apr 2026 13:49:48 +0300 Subject: [PATCH 09/16] Update functions_vladyslav_senkiv.py --- Week04/functions_vladyslav_senkiv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_vladyslav_senkiv.py b/Week04/functions_vladyslav_senkiv.py index be7eca34..bea89824 100644 --- a/Week04/functions_vladyslav_senkiv.py +++ b/Week04/functions_vladyslav_senkiv.py @@ -26,7 +26,7 @@ def custom_equation( return float((x**a + y**b) / c) -def fn_w_counter() -> Tuple[int, Dict[str, int]]: +def fn_w_counter() -> (int, dict[str, int]): """Count total calls and calls grouped by caller module name.""" if not hasattr(fn_w_counter, "total_calls"): fn_w_counter.total_calls = 0 From befb2e82e91f52589e41734bd178136f0fc3bba7 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 5 May 2026 10:28:40 +0300 Subject: [PATCH 10/16] Update functions_vladyslav_senkiv.py --- Week04/functions_vladyslav_senkiv.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Week04/functions_vladyslav_senkiv.py b/Week04/functions_vladyslav_senkiv.py index bea89824..f45074cc 100644 --- a/Week04/functions_vladyslav_senkiv.py +++ b/Week04/functions_vladyslav_senkiv.py @@ -1,7 +1,5 @@ -import inspect from typing import Dict, Tuple - custom_power = lambda x=0, /, e=1: x**e @@ -14,7 +12,8 @@ def custom_equation( *, c: int = 1, ) -> float: - """Calculate a custom equation. + """ + Calculate a custom equation. :param x: First base value. :param y: Second base value. @@ -26,16 +25,17 @@ def custom_equation( return float((x**a + y**b) / c) -def fn_w_counter() -> (int, dict[str, int]): - """Count total calls and calls grouped by caller module name.""" +def fn_w_counter() -> Tuple[int, Dict[str, int]]: + """Count total calls and calls grouped by this module name.""" if not hasattr(fn_w_counter, "total_calls"): fn_w_counter.total_calls = 0 fn_w_counter.caller_counts = {} - caller_frame = inspect.currentframe().f_back - caller_name = caller_frame.f_globals.get("__name__", "__main__") + module_name = __name__ fn_w_counter.total_calls += 1 - fn_w_counter.caller_counts[caller_name] = fn_w_counter.caller_counts.get(caller_name, 0) + 1 + fn_w_counter.caller_counts[module_name] = ( + fn_w_counter.caller_counts.get(module_name, 0) + 1 + ) return fn_w_counter.total_calls, dict(fn_w_counter.caller_counts) From da68022ace6311b9fb61c5b9f445c2a8da948120 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 5 May 2026 10:34:20 +0300 Subject: [PATCH 11/16] Update type hints for fn_w_counter function --- Week04/functions_vladyslav_senkiv.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Week04/functions_vladyslav_senkiv.py b/Week04/functions_vladyslav_senkiv.py index f45074cc..7035e3dc 100644 --- a/Week04/functions_vladyslav_senkiv.py +++ b/Week04/functions_vladyslav_senkiv.py @@ -1,5 +1,3 @@ -from typing import Dict, Tuple - custom_power = lambda x=0, /, e=1: x**e @@ -25,7 +23,7 @@ def custom_equation( return float((x**a + y**b) / c) -def fn_w_counter() -> Tuple[int, Dict[str, int]]: +def fn_w_counter() -> tuple[int, dict[str, int]]: """Count total calls and calls grouped by this module name.""" if not hasattr(fn_w_counter, "total_calls"): fn_w_counter.total_calls = 0 From 24ec4db21383a5aee9f8efd5c33aca21a50d6865 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 5 May 2026 10:35:51 +0300 Subject: [PATCH 12/16] Update functions_vladyslav_senkiv.py --- Week04/functions_vladyslav_senkiv.py | 68 ++++++++++++---------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/Week04/functions_vladyslav_senkiv.py b/Week04/functions_vladyslav_senkiv.py index 7035e3dc..0cfc474e 100644 --- a/Week04/functions_vladyslav_senkiv.py +++ b/Week04/functions_vladyslav_senkiv.py @@ -1,39 +1,29 @@ -custom_power = lambda x=0, /, e=1: x**e - - -def custom_equation( - x: int = 0, - y: int = 0, - /, - a: int = 1, - b: int = 1, - *, - c: int = 1, -) -> float: - """ - Calculate a custom equation. - - :param x: First base value. - :param y: Second base value. - :param a: Exponent for x. - :param b: Exponent for y. - :param c: Divisor value. - :returns: The result of (x**a + y**b) / c. - """ - return float((x**a + y**b) / c) - - -def fn_w_counter() -> tuple[int, dict[str, int]]: - """Count total calls and calls grouped by this module name.""" - if not hasattr(fn_w_counter, "total_calls"): - fn_w_counter.total_calls = 0 - fn_w_counter.caller_counts = {} - - module_name = __name__ - - fn_w_counter.total_calls += 1 - fn_w_counter.caller_counts[module_name] = ( - fn_w_counter.caller_counts.get(module_name, 0) + 1 - ) - - return fn_w_counter.total_calls, dict(fn_w_counter.caller_counts) + +custom_power = lambda x=0,/, e=1 : x ** e + + +def custom_equation(x: int = 0 , y: int = 0 , /, a: int = 1, b: int=1 , * , c: int = 1) -> float : + """ + This function returns the result of an operation based on the specified base and exponent values. + + :param x: First base value + :param y: Second base value + :param a: First exponent value + :param b: Second exponent value + :param c: Divisor value + :return: (x*a + y*b)/c + """ + return (x**a + y**b)/c + + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "calls"): + fn_w_counter.calls = 0 + + fn_w_counter.calls += 1 + + return fn_w_counter.calls, {__name__: fn_w_counter.calls} + + + + From d051de8bb0603336aab9c94c912dcd5eae7b1f3b Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 5 May 2026 10:40:52 +0300 Subject: [PATCH 13/16] Update decorators_vladyslav_senkiv.py --- Week04/decorators_vladyslav_senkiv.py | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Week04/decorators_vladyslav_senkiv.py b/Week04/decorators_vladyslav_senkiv.py index f1d5e232..1be275d3 100644 --- a/Week04/decorators_vladyslav_senkiv.py +++ b/Week04/decorators_vladyslav_senkiv.py @@ -1,28 +1,28 @@ -from functools import wraps -from time import perf_counter +import functools +import time import tracemalloc - def performance(func): - - @wraps(func) + @functools.wraps(func) def wrapper(*args, **kwargs): - wrapper.counter += 1 - tracemalloc.start() - start = perf_counter() - try: - return func(*args, **kwargs) - finally: - elapsed = perf_counter() - start - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() + start_time = time.perf_counter() + + result = func(*args, **kwargs) - wrapper.total_time += elapsed - wrapper.total_mem += peak + end_time = time.perf_counter() + current_mem, peak_mem = tracemalloc.get_traced_memory() + tracemalloc.stop() + + wrapper.counter += 1 + wrapper.total_time += end_time - start_time + wrapper.total_mem += peak_mem + + return result wrapper.counter = 0 wrapper.total_time = 0.0 wrapper.total_mem = 0 + return wrapper From 8fdb8b308573e04b9cb2434b868099e1058cc19a Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 5 May 2026 10:43:38 +0300 Subject: [PATCH 14/16] Update decorators_vladyslav_senkiv.py --- Week04/decorators_vladyslav_senkiv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Week04/decorators_vladyslav_senkiv.py b/Week04/decorators_vladyslav_senkiv.py index 1be275d3..15c43777 100644 --- a/Week04/decorators_vladyslav_senkiv.py +++ b/Week04/decorators_vladyslav_senkiv.py @@ -7,17 +7,17 @@ def performance(func): @functools.wraps(func) def wrapper(*args, **kwargs): tracemalloc.start() - start_time = time.perf_counter() + start = time.perf_counter() result = func(*args, **kwargs) - end_time = time.perf_counter() - current_mem, peak_mem = tracemalloc.get_traced_memory() + end = time.perf_counter() + current, peak = tracemalloc.get_traced_memory() tracemalloc.stop() wrapper.counter += 1 - wrapper.total_time += end_time - start_time - wrapper.total_mem += peak_mem + wrapper.total_time += end - start + wrapper.total_mem += peak return result From 5cda0023c535f8fc79cead72e9a8039f13135fd2 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 5 May 2026 10:46:12 +0300 Subject: [PATCH 15/16] Delete Week04/decorators_vladyslav_senkiv.py --- Week04/decorators_vladyslav_senkiv.py | 28 --------------------------- 1 file changed, 28 deletions(-) delete mode 100644 Week04/decorators_vladyslav_senkiv.py diff --git a/Week04/decorators_vladyslav_senkiv.py b/Week04/decorators_vladyslav_senkiv.py deleted file mode 100644 index 15c43777..00000000 --- a/Week04/decorators_vladyslav_senkiv.py +++ /dev/null @@ -1,28 +0,0 @@ -import functools -import time -import tracemalloc - - -def performance(func): - @functools.wraps(func) - def wrapper(*args, **kwargs): - tracemalloc.start() - start = time.perf_counter() - - result = func(*args, **kwargs) - - end = time.perf_counter() - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - - wrapper.counter += 1 - wrapper.total_time += end - start - wrapper.total_mem += peak - - return result - - wrapper.counter = 0 - wrapper.total_time = 0.0 - wrapper.total_mem = 0 - - return wrapper From 247854199a3d6b0d471ef178b5c539df5adc1981 Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 5 May 2026 10:46:27 +0300 Subject: [PATCH 16/16] Delete Week04/functions_vladyslav_senkiv.py --- Week04/functions_vladyslav_senkiv.py | 29 ---------------------------- 1 file changed, 29 deletions(-) delete mode 100644 Week04/functions_vladyslav_senkiv.py diff --git a/Week04/functions_vladyslav_senkiv.py b/Week04/functions_vladyslav_senkiv.py deleted file mode 100644 index 0cfc474e..00000000 --- a/Week04/functions_vladyslav_senkiv.py +++ /dev/null @@ -1,29 +0,0 @@ - -custom_power = lambda x=0,/, e=1 : x ** e - - -def custom_equation(x: int = 0 , y: int = 0 , /, a: int = 1, b: int=1 , * , c: int = 1) -> float : - """ - This function returns the result of an operation based on the specified base and exponent values. - - :param x: First base value - :param y: Second base value - :param a: First exponent value - :param b: Second exponent value - :param c: Divisor value - :return: (x*a + y*b)/c - """ - return (x**a + y**b)/c - - -def fn_w_counter() -> (int, dict[str, int]): - if not hasattr(fn_w_counter, "calls"): - fn_w_counter.calls = 0 - - fn_w_counter.calls += 1 - - return fn_w_counter.calls, {__name__: fn_w_counter.calls} - - - -