Skip to content

Commit dcc00d2

Browse files
authored
Merge pull request canbula#480 from gorendes/patch-2
Create pyramid_niyazi_cetinkaya.py
2 parents b73e7df + 9c6494b commit dcc00d2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Week03/pyramid_niyazi_cetinkaya.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+
height = 0 # Start with height 0
3+
4+
# Loop until blocks required for the next level exceed available blocks
5+
while (height * (height + 1)) // 2 <= number_of_blocks:
6+
height += 1
7+
8+
return height - 1 # Subtract 1 to get the maximum achievable height
9+
10+

0 commit comments

Comments
 (0)