Skip to content

Commit 4431d5c

Browse files
authored
Merge pull request #965 from ckaemm/master
week3_hw
2 parents 9a05b96 + 0f9e19e commit 4431d5c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Week03/pyramid_cemil_koca.py

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

Week03/sequences_cemil_koca.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def remove_duplicates(seq):
2+
result = []
3+
for item in seq:
4+
if item not in result:
5+
result.append(item)
6+
return result
7+
8+
9+
def list_counts(seq):
10+
counts = {}
11+
for item in seq:
12+
if item not in counts:
13+
counts[item] = 0
14+
counts[item] += 1
15+
return counts
16+
17+
18+
def reverse_dict(d):
19+
result = {}
20+
for key in d:
21+
result[d[key]] = key
22+
return result

0 commit comments

Comments
 (0)