Skip to content

Commit 228e44a

Browse files
authored
Merge pull request canbula#500 from egeenc0/master
Homework
2 parents 640b89b + 9e68344 commit 228e44a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Week03/pyramid_ege_enc.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
n = 1
3+
height = 0
4+
5+
while number_of_blocks >= n:
6+
height += 1
7+
number_of_blocks -= n
8+
n += 1
9+
10+
return height

Week03/sequences_ege_enc.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def remove_duplicates(seq : list) -> list:
2+
return list(set(seq))
3+
4+
def list_counts(seq:list) -> dict:
5+
d = {}
6+
for i in seq:
7+
if i in d:
8+
d[i] += 1
9+
else:
10+
d[i] = 1
11+
return d
12+
13+
def reverse_dict(d : dict) -> dict:
14+
nd = {}
15+
for i, h in d.items():
16+
nd[h] = i
17+
return nd

0 commit comments

Comments
 (0)