Skip to content

Commit b6db8ea

Browse files
authored
Implement pyramid height calculation function
Adds a function to calculate the height of a pyramid based on the number of blocks.
1 parent 71f5b39 commit b6db8ea

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Week03/pyramid_dilara_agac.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
"""
3+
This function calculates the height of a pyramid
4+
that can be built with the given number of blocks.
5+
"""
6+
height = 0
7+
used_blocks = 0
8+
9+
while used_blocks + (height + 1) <= number_of_blocks:
10+
height += 1
11+
used_blocks += height
12+
13+
return height

0 commit comments

Comments
 (0)