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_beyza_arman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def calculate_pyramid_height(blocks):
"""Return the number of complete layers that can be built."""
height = 0
next_layer = 1
while blocks >= next_layer:
blocks -= next_layer
height += 1
next_layer += 1
return height
20 changes: 20 additions & 0 deletions Week03/sequences_beyza_arman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def remove_duplicates(items):
"""Remove duplicates while preserving the first occurrence order."""
result = []
for item in items:
if item not in result:
result.append(item)
return result


def list_counts(items):
"""Return the frequency of each item."""
counts = {}
for item in items:
counts[item] = counts.get(item, 0) + 1
return counts


def reverse_dict(mapping):
"""Swap keys and values; the last key wins for repeated values."""
return {value: key for key, value in mapping.items()}
Loading