From 752548b74252b3eb5ff76c2bf18ae7592378bee4 Mon Sep 17 00:00:00 2001 From: Esra Sepik Date: Thu, 15 Oct 2026 04:24:29 -0700 Subject: [PATCH 1/2] Add function to calculate pyramid height --- Week03/pyramid_esra_sepik.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Week03/pyramid_esra_sepik.py diff --git a/Week03/pyramid_esra_sepik.py b/Week03/pyramid_esra_sepik.py new file mode 100644 index 000000000..98ce056b2 --- /dev/null +++ b/Week03/pyramid_esra_sepik.py @@ -0,0 +1,7 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + used_blocks = 0 + while used_blocks + (height + 1) <= number_of_blocks: + height += 1 + used_blocks += height + return height From 945f7c8454e2859b90075b2bea659125c9ff73b6 Mon Sep 17 00:00:00 2001 From: Esra Sepik Date: Thu, 15 Oct 2026 04:29:32 -0700 Subject: [PATCH 2/2] Implement utility functions for list and dict operations Added functions to remove duplicates from a list, count occurrences of items in a list, and reverse a dictionary. --- Week03/sequences_esra_sepik.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Week03/sequences_esra_sepik.py diff --git a/Week03/sequences_esra_sepik.py b/Week03/sequences_esra_sepik.py new file mode 100644 index 000000000..1cb5d5906 --- /dev/null +++ b/Week03/sequences_esra_sepik.py @@ -0,0 +1,22 @@ +def remove_duplicates(seq: list) -> list: + """ + This function removes duplicates from a list. + """ + return list(dict.fromkeys(seq)) + + +def list_counts(seq: list) -> dict: + """ + This function counts the number of occurrences of each item in a list. + """ + return {item: seq.count(item) for item in seq} + + +def reverse_dict(d: dict) -> dict: + """ + This function reverses the keys and values of a dictionary. + """ + reversed_d = {} + for key, value in d.items(): + reversed_d[value] = key + return reversed_d