From 95675ea482323a00adacf224b07f53a2bb3f5e8f Mon Sep 17 00:00:00 2001 From: Senkiv Vladyslav Date: Tue, 10 Mar 2026 13:39:44 +0300 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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