diff --git a/Week03/pyramid_sultan_yuksel.py b/Week03/pyramid_sultan_yuksel.py new file mode 100644 index 00000000..26e901cf --- /dev/null +++ b/Week03/pyramid_sultan_yuksel.py @@ -0,0 +1,8 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 # Inıtıal height + needed_blocks = 1 # Number of blocks required inıtıally + while number_of_blocks >= needed_blocks: + number_of_blocks -= needed_blocks + height += 1 + needed_blocks += 1 + return height diff --git a/Week03/sequences_sultan_yuksel.py b/Week03/sequences_sultan_yuksel.py new file mode 100644 index 00000000..a92d8347 --- /dev/null +++ b/Week03/sequences_sultan_yuksel.py @@ -0,0 +1,21 @@ +def remove_duplicates(seq: list) -> list: + new_list = [] + for i in seq: + if i not in new_list: + new_list.append(i) + return new_list + +def list_counts(seq: list) -> dict: + counts = {} + for i in seq: + if i in counts: + counts[i] += 1 + else: + counts[i] = 1 + return counts + +def reverse_dict(d: dict) ->dict: + new_dict = {} + for key, value in d.items(): + new_dict[value] = key + return new_dict