Skip to content

Commit 8bf8653

Browse files
Add function to calculate pyramid height from blocks
1 parent 71f5b39 commit 8bf8653

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
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+
needed_for_next_level = 1
4+
while number_of_blocks >= needed_for_next_level:
5+
number_of_blocks -= needed_for_next_level
6+
height += 1
7+
needed_for_next_level += 1
8+
9+
return height

0 commit comments

Comments
 (0)