Skip to content

Commit 213e67a

Browse files
authored
Merge pull request #446 from BerkeAlpaslan/patch-3
Create pyramid_berke_alpaslan.py
2 parents acd18e1 + 6171a8c commit 213e67a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Week03/pyramid_berke_alpaslan.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+
for i in range(number_of_blocks):
4+
height += 1
5+
if height * (height + 1) / 2 > number_of_blocks:
6+
height -= 1
7+
break
8+
return height

0 commit comments

Comments
 (0)