Skip to content

Commit a6c74cd

Browse files
authored
Add function to calculate pyramid height from blocks
1 parent 4b1f345 commit a6c74cd

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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)