From e522a6c79dfeaa0c8708126a6d35f9b2815fd87f Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Fri, 14 Nov 2025 20:34:20 +0300 Subject: [PATCH 1/5] Week03 homeworks done --- Week03/pyramid_tarik_bozgan.py | 8 ++++++++ Week03/sequences_tarik_bozgan.py | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 Week03/pyramid_tarik_bozgan.py create mode 100644 Week03/sequences_tarik_bozgan.py diff --git a/Week03/pyramid_tarik_bozgan.py b/Week03/pyramid_tarik_bozgan.py new file mode 100644 index 0000000..18bd717 --- /dev/null +++ b/Week03/pyramid_tarik_bozgan.py @@ -0,0 +1,8 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + while number_of_blocks >= 0: + height += 1 + number_of_blocks -= height + return height - 1 + +print(calculate_pyramid_height(10)) \ No newline at end of file diff --git a/Week03/sequences_tarik_bozgan.py b/Week03/sequences_tarik_bozgan.py new file mode 100644 index 0000000..1ba0206 --- /dev/null +++ b/Week03/sequences_tarik_bozgan.py @@ -0,0 +1,23 @@ +def remove_duplicates(seq): + result = [] + for item in seq: + if item not in result: + result.append(item) + return result + + +def list_counts(seq): + counts = {} + for item in seq: + if item in counts: + counts[item] += 1 + else: + counts[item] = 1 + return counts + + +def reverse_dict(d): + reversed_dict = {} + for key, value in d.items(): + reversed_dict[value] = key + return reversed_dict \ No newline at end of file From cbdc93516e86d608fa06d2c69c91bbaef6ab57ad Mon Sep 17 00:00:00 2001 From: protagonist9 <156001177+protagonist9@users.noreply.github.com> Date: Fri, 14 Nov 2025 20:35:52 +0300 Subject: [PATCH 2/5] Week03 homeworks done --- Week03/pyramid_tarik_bozgan.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Week03/pyramid_tarik_bozgan.py b/Week03/pyramid_tarik_bozgan.py index 18bd717..9bd324b 100644 --- a/Week03/pyramid_tarik_bozgan.py +++ b/Week03/pyramid_tarik_bozgan.py @@ -4,5 +4,3 @@ def calculate_pyramid_height(number_of_blocks): height += 1 number_of_blocks -= height return height - 1 - -print(calculate_pyramid_height(10)) \ No newline at end of file From caaf8062125192227095bc5382d2c9646a8649c3 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Fri, 14 Nov 2025 20:41:39 +0300 Subject: [PATCH 3/5] Created arrays_tarik_bozgan.py --- Week04/arrays_tarik_bozgan.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Week04/arrays_tarik_bozgan.py diff --git a/Week04/arrays_tarik_bozgan.py b/Week04/arrays_tarik_bozgan.py new file mode 100644 index 0000000..24f4976 --- /dev/null +++ b/Week04/arrays_tarik_bozgan.py @@ -0,0 +1,20 @@ +import numpy as np + +def replace_center_with_minus_one(d, n, m): + if m > n: + raise ValueError("m cannot be greater than n") + if d <= 0: + raise ValueError("d must be greater than 0") + if n < 0: + raise ValueError("n must be greater than or equal to 0") + if m < 0: + raise ValueError("m must be greater than or equal to 0") + + array = np.random.randint(10**d, size=n) + + start_index = (n - m) // 2 + end_index = start_index + m + + array[start_index:end_index] = -1 + + return array \ No newline at end of file From a54778b5040dabd160dead572f01a11b81b5f59b Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Fri, 14 Nov 2025 20:44:27 +0300 Subject: [PATCH 4/5] Created arrays_tarik_bozgan.py --- Week04/arrays_tarik_bozgan.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Week04/arrays_tarik_bozgan.py b/Week04/arrays_tarik_bozgan.py index 24f4976..1a521ab 100644 --- a/Week04/arrays_tarik_bozgan.py +++ b/Week04/arrays_tarik_bozgan.py @@ -10,11 +10,12 @@ def replace_center_with_minus_one(d, n, m): if m < 0: raise ValueError("m must be greater than or equal to 0") - array = np.random.randint(10**d, size=n) + arr = np.random.randint(10**d, size=n) start_index = (n - m) // 2 end_index = start_index + m - array[start_index:end_index] = -1 + for i in range(start_index, end_index): + arr[i] = -1 - return array \ No newline at end of file + return arr \ No newline at end of file From b60ab3bad05c63ba8c5ff07c1c2d332bc08cbb35 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Fri, 14 Nov 2025 20:49:37 +0300 Subject: [PATCH 5/5] Created arrays_tarik_bozgan.py --- Week04/arrays_tarik_bozgan.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Week04/arrays_tarik_bozgan.py b/Week04/arrays_tarik_bozgan.py index 1a521ab..2d51c11 100644 --- a/Week04/arrays_tarik_bozgan.py +++ b/Week04/arrays_tarik_bozgan.py @@ -10,12 +10,11 @@ def replace_center_with_minus_one(d, n, m): if m < 0: raise ValueError("m must be greater than or equal to 0") - arr = np.random.randint(10**d, size=n) + arr = np.random.randint(10**(d-1), 10**d, size=(n, n)) start_index = (n - m) // 2 end_index = start_index + m - for i in range(start_index, end_index): - arr[i] = -1 + arr[start_index:end_index, start_index:end_index] = -1 return arr \ No newline at end of file