Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Week03/pyramid_yunus_dermencioglu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def calculate_pyramid_height(number_of_blocks):
height = 0

# Calculate the maximum pyramid height
while number_of_blocks >= height + 1:
height += 1
number_of_blocks -= height

return height
32 changes: 32 additions & 0 deletions Week03/sequences_yunus_dermencioglu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Remove duplicate elements from a list
def remove_duplicates(seq: list) -> list:
result = []

for item in seq:
if item not in result:
result.append(item)

return result


# Count the occurrences of each element in a list
def list_counts(seq: list) -> dict:
counts = {}

for item in seq:
if item in counts:
counts[item] += 1
else:
counts[item] = 1

return counts


# Swap the keys and values of a dictionary
def reverse_dict(d: dict) -> dict:
reversed_dict = {}

for key, value in d.items():
reversed_dict[value] = key

return reversed_dict
Loading