Skip to content

Commit 3c745e6

Browse files
Add function to calculate pyramid height from blocks
1 parent 93f8dd6 commit 3c745e6

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎Week03/pyramid_alisher_shalenov.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
total = 0
3+
height = 0
4+
for i in range(1, number_of_blocks + 1):
5+
total += i
6+
if total > number_of_blocks:
7+
break
8+
else:
9+
height = i
10+
return height

0 commit comments

Comments
 (0)