Skip to content

Commit 2c737e9

Browse files
authored
Merge pull request canbula#526 from doganenes/master
Create sequences_enes_dogan.py
2 parents 0b01b82 + a6ed162 commit 2c737e9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Week03/pyramid_enes_dogan.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+
4+
while number_of_blocks >= (height + 1):
5+
height += 1
6+
number_of_blocks -= height
7+
8+
return height

Week03/sequences_enes_dogan.py

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

0 commit comments

Comments
 (0)