Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
95675ea
Add function to calculate pyramid height
Sharik3k Mar 10, 2026
7446839
Rename pyramid_senkiv_vladyslav to pyramid_senkiv_vladyslav.py
Sharik3k Mar 10, 2026
a657189
Merge branch 'canbula:master' into master
Sharik3k Mar 17, 2026
96bed4c
Merge branch 'canbula:master' into master
Sharik3k Mar 23, 2026
428d74c
Merge branch 'canbula:master' into master
Sharik3k Mar 24, 2026
01d0492
Merge branch 'canbula:master' into master
Sharik3k Mar 28, 2026
d4283e9
Rename pyramid_senkiv_vladyslav.py to pyramid_vladyslav_senkiv.py
Sharik3k Mar 28, 2026
ce2a6ec
Merge branch 'canbula:master' into master
Sharik3k Apr 4, 2026
cab2353
add sequences_vladyslav_senkiv.py
Sharik3k Apr 5, 2026
2914844
Create decorators_vladyslav_senkiv.py
Sharik3k Apr 5, 2026
a342200
Create functions_vladyslav_senkiv.py
Sharik3k Apr 5, 2026
4ee7ef0
Create awaitme_vladyslav_senkiv.py
Sharik3k Apr 5, 2026
293ce8e
Create timer_vladyslav_senkiv.py
Sharik3k Apr 5, 2026
6efe4a9
Update functions_vladyslav_senkiv.py
Sharik3k Apr 20, 2026
befb2e8
Update functions_vladyslav_senkiv.py
Sharik3k May 5, 2026
6846d1c
Merge branch 'canbula:master' into master
Sharik3k May 5, 2026
da68022
Update type hints for fn_w_counter function
Sharik3k May 5, 2026
24ec4db
Update functions_vladyslav_senkiv.py
Sharik3k May 5, 2026
d051de8
Update decorators_vladyslav_senkiv.py
Sharik3k May 5, 2026
8fdb8b3
Update decorators_vladyslav_senkiv.py
Sharik3k May 5, 2026
5cda002
Delete Week04/decorators_vladyslav_senkiv.py
Sharik3k May 5, 2026
2478541
Delete Week04/functions_vladyslav_senkiv.py
Sharik3k May 5, 2026
219ffd8
Merge branch 'canbula:master' into master
Sharik3k Jun 3, 2026
af8267a
Update pyramid_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
1ef3815
Update sequences_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
802c4b9
Create functions_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
74e2f05
Create decorators_vladyslav.senkiv.py
Sharik3k Jun 3, 2026
22c8d37
Update awaitme_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
df93bbc
Update timer_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
0839de5
Create threaded_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
820f247
Create estimate_pi_w_threads_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
197b380
Create dining_philosophers_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
343493c
Create dining_philosophers_vladyslav_senkiv.py
Sharik3k Jun 3, 2026
628e6a3
fix
Sharik3k Jun 3, 2026
0ad8bc4
fix week 4
Sharik3k Jun 3, 2026
bcb1f41
fix week 4 decorators
Sharik3k Jun 3, 2026
366b85a
Update decorators_vladyslav.senkiv.py
Sharik3k Jun 3, 2026
e975e60
fix
Sharik3k Jun 3, 2026
8460cd6
Update decorators_vladyslav.senkiv.py
Sharik3k Jun 3, 2026
9b9cca5
Fix memory calculation for list results in decorator
Sharik3k Jun 3, 2026
e87c3f7
x
Sharik3k Jun 3, 2026
c3618f5
Delete dining_philosophers_vladyslav_senkiv.py
Sharik3k Jun 4, 2026
f7884a5
Merge branch 'canbula:master' into master
Sharik3k Jun 4, 2026
33cfd59
Delete Week09/dining_philosophers_vladyslav_senkiv.py
canbula Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Week03/pyramid_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def calculate_pyramid_height(number_of_blocks):
height = 0
needed_blocks = 1

while number_of_blocks >= needed_blocks:
number_of_blocks -= needed_blocks
height += 1
needed_blocks += 1

return height
29 changes: 29 additions & 0 deletions Week03/sequences_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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:
result = {}

for item in seq:
if item in result:
result[item] += 1
else:
result[item] = 1

return result


def reverse_dict(d: dict) -> dict:
result = {}

for key, value in d.items():
result[value] = key

return result
32 changes: 32 additions & 0 deletions Week04/decorators_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import time
import sys
from functools import wraps


def performance(func):
@wraps(func)
def wrapper(*args, **kwargs):
start_time = time.perf_counter()

result = func(*args, **kwargs)

end_time = time.perf_counter()

performance.counter += 1
performance.total_time += end_time - start_time
performance.total_mem += sys.getsizeof(result)

if isinstance(result, list):
performance.total_mem += sys.getsizeof(result)

for item in result:
performance.total_mem += sys.getsizeof(item)

return result

return wrapper


performance.counter = 0
performance.total_time = 0
performance.total_mem = 0
41 changes: 41 additions & 0 deletions Week04/functions_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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:
"""
Calculates custom equation.

:param x: first number
:param y: second number
:param a: additional parameter
:param b: power value
:param c: divisor
:return: result of custom equation
"""

values = [x, y, a, b, c]

for value in values:
if not isinstance(value, int):
raise TypeError("value must be int")

return (x + y ** b) / c


counter = 0


def fn_w_counter() -> (int, dict[str, int]):
global counter

counter += 1

return counter, {__name__: counter}
9 changes: 9 additions & 0 deletions Week05/awaitme_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from functools import wraps


def awaitme(func):
@wraps(func)
async def wrapper(*args, **kwargs):
return func(*args, **kwargs)

return wrapper
15 changes: 15 additions & 0 deletions Week06/timer_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -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_value, traceback):
self.end_time = perf_counter()
return False
25 changes: 25 additions & 0 deletions Week07/threaded_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import threading
from functools import wraps


def threaded(number_of_threads):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
threads = []

for _ in range(number_of_threads):
thread = threading.Thread(
target=func,
args=args,
kwargs=kwargs
)
threads.append(thread)
thread.start()

for thread in threads:
thread.join()

return wrapper

return decorator
47 changes: 47 additions & 0 deletions Week08/estimate_pi_w_threads_vladyslav_senkiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import random
import threading
import math


class PiWorker(threading.Thread):
def __init__(self, points_count):
super().__init__()
self.points_count = points_count
self.inside_circle = 0

def run(self):
for _ in range(self.points_count):
x = random.random()
y = random.random()

if x * x + y * y <= 1:
self.inside_circle += 1


def estimate_pi(total_points=1000000, thread_count=4):
points_per_thread = total_points // thread_count
threads = []

for _ in range(thread_count):
thread = PiWorker(points_per_thread)
threads.append(thread)
thread.start()

inside_circle = 0

for thread in threads:
thread.join()
inside_circle += thread.inside_circle

used_points = points_per_thread * thread_count
pi_value = 4 * inside_circle / used_points

return pi_value


if __name__ == "__main__":
pi = estimate_pi(total_points=1000000, thread_count=4)

print("Estimated PI:", pi)
print("Real PI:", math.pi)
print("Difference:", abs(math.pi - pi))
Loading