We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 71f5b39 commit e88db65Copy full SHA for e88db65
Week03/pyramid_first_last.py
@@ -0,0 +1,18 @@
1
+def calculate_pyramid_height(number_of_blocks):
2
+ """
3
+ This function calculates the height of a pyramid
4
+ given the number of blocks available.
5
+
6
+ A pyramid has 1 block at top, 2 blocks in second row,
7
+ 3 blocks in third row, etc.
8
9
+ Returns the maximum height that can be built.
10
11
+ height = 0
12
+ total_blocks_used = 0
13
14
+ while total_blocks_used + (height + 1) <= number_of_blocks:
15
+ height += 1
16
+ total_blocks_used += height
17
18
+ return height
0 commit comments