diff --git a/Week03/pyramid_aleyna_gultekin.py b/Week03/pyramid_aleyna_gultekin.py new file mode 100644 index 000000000..7322de282 --- /dev/null +++ b/Week03/pyramid_aleyna_gultekin.py @@ -0,0 +1,6 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + while number_of_blocks >= height + 1: + height += 1 + number_of_blocks -= height + return height diff --git a/Week03/sequences_aleyna_gultekin.py b/Week03/sequences_aleyna_gultekin.py new file mode 100644 index 000000000..ae31fb733 --- /dev/null +++ b/Week03/sequences_aleyna_gultekin.py @@ -0,0 +1,26 @@ +def remove_duplicates(seq: list) -> list: + """ + This function removes duplicates from a list. + """ + result = [] + for item in seq: + if item not in result: + result.append(item) + return result + + +def list_counts(seq: list) -> dict: + """ + This function counts the number of occurrences of each item in a list. + """ + counts = {} + for item in seq: + counts[item] = counts.get(item, 0) + 1 + return counts + + +def reverse_dict(d: dict) -> dict: + """ + This function reverses the keys and values of a dictionary. + """ + return {value: key for key, value in d.items()}