From 1b07c9b26194092b93bf8ad2db82602adda79bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20Koray=20B=C3=BClb=C3=BCl?= <240315006@ogr.cbu.edu.tr> Date: Tue, 3 Mar 2026 14:12:36 +0300 Subject: [PATCH 1/4] HW3-Part1 --- Week03/pyramid_gokhan_koray_bulbul.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Week03/pyramid_gokhan_koray_bulbul.py diff --git a/Week03/pyramid_gokhan_koray_bulbul.py b/Week03/pyramid_gokhan_koray_bulbul.py new file mode 100644 index 00000000..8de2d19a --- /dev/null +++ b/Week03/pyramid_gokhan_koray_bulbul.py @@ -0,0 +1,5 @@ +def calculate_pyramid_height(number_of_blocks): + height = 1 + while True: + if((a := a - height) <= height): return height + height += 1 From 9682aaf195d85ba184cde2291516f4a0fb2c7d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20Koray=20B=C3=BClb=C3=BCl?= <240315006@ogr.cbu.edu.tr> Date: Tue, 3 Mar 2026 14:15:51 +0300 Subject: [PATCH 2/4] Delete Week03/pyramid_gokhan_koray_bulbul.py --- Week03/pyramid_gokhan_koray_bulbul.py | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Week03/pyramid_gokhan_koray_bulbul.py diff --git a/Week03/pyramid_gokhan_koray_bulbul.py b/Week03/pyramid_gokhan_koray_bulbul.py deleted file mode 100644 index 8de2d19a..00000000 --- a/Week03/pyramid_gokhan_koray_bulbul.py +++ /dev/null @@ -1,5 +0,0 @@ -def calculate_pyramid_height(number_of_blocks): - height = 1 - while True: - if((a := a - height) <= height): return height - height += 1 From a2455bcf295ddec886458050a340160435df2ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20Koray=20B=C3=BClb=C3=BCl?= <240315006@ogr.cbu.edu.tr> Date: Tue, 3 Mar 2026 14:48:58 +0300 Subject: [PATCH 3/4] HW3-Part1 --- Week03/pyramid_gokhan_koray_bulbul.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Week03/pyramid_gokhan_koray_bulbul.py diff --git a/Week03/pyramid_gokhan_koray_bulbul.py b/Week03/pyramid_gokhan_koray_bulbul.py new file mode 100644 index 00000000..d975e649 --- /dev/null +++ b/Week03/pyramid_gokhan_koray_bulbul.py @@ -0,0 +1,9 @@ +def calculate_pyramid_height(number_of_blocks): + # Input precautions + if (not isinstance(number_of_blocks, int)) or (number_of_blocks < 0): + raise TypeError("number_of_blocks must be a non-negative whole integer.") + + height = 1 + while True: + if(number_of_blocks := number_of_blocks - height) <= height: return height + height += 1 From a50f9fcf69c53eea94ba2b21c46abd539f072ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20Koray=20B=C3=BClb=C3=BCl?= <240315006@ogr.cbu.edu.tr> Date: Tue, 3 Mar 2026 15:43:19 +0300 Subject: [PATCH 4/4] HW3-Part2 --- Week03/sequences_gokhan_koray_bulbul.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Week03/sequences_gokhan_koray_bulbul.py diff --git a/Week03/sequences_gokhan_koray_bulbul.py b/Week03/sequences_gokhan_koray_bulbul.py new file mode 100644 index 00000000..9eb2d437 --- /dev/null +++ b/Week03/sequences_gokhan_koray_bulbul.py @@ -0,0 +1,21 @@ +def remove_duplicates(seq: list) -> list: + # returning list(set(seq)) would not preserve order + unique_set = set() + result = [] + for item in seq: + if item not in unique_set: + result.append(item) + unique_set.add(item) + return result + +def list_counts(seq: list) -> dict: + occurance_dict = dict.fromkeys(seq, 0) + for item in seq: + occurance_dict[item] += 1 + return occurance_dict + +def reverse_dict(d: dict) -> dict: + reversed_dict = dict() + for key, value in d.items(): + reversed_dict[value] = key + return reversed_dict