Skip to content

Commit 39cac7b

Browse files
authored
Add files via upload
1 parent 39ad9db commit 39cac7b

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎Week03/pyramid_yagiz_cengiz.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
height = 0
3+
needed_blocks = 1
4+
while number_of_blocks >= needed_blocks:
5+
number_of_blocks -= needed_blocks
6+
height += 1
7+
needed_blocks += 1
8+
return height

‎Week03/sequences_yagiz_cengiz.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def remove_duplicates(seq: list) -> list:
2+
"""
3+
This function removes duplicates from a list.
4+
"""
5+
result = []
6+
for item in seq:
7+
if item not in result:
8+
result.append(item)
9+
return result
10+
11+
12+
def list_counts(seq: list) -> dict:
13+
"""
14+
This function counts the number of occurrences of each item in a list.
15+
"""
16+
counts = {}
17+
for item in seq:
18+
counts[item] = counts.get(item, 0) + 1
19+
return counts
20+
21+
22+
def reverse_dict(d: dict) -> dict:
23+
"""
24+
This function reverses the keys and values of a dictionary.
25+
"""
26+
return {value: key for key, value in d.items()}

0 commit comments

Comments
 (0)