Skip to content

Commit cb30cab

Browse files
Add function to calculate pyramid height from blocks
1 parent f083b29 commit cb30cab

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎Week03/pyramid_ayse_arslan.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
height = 0
3+
blocks_used = 0
4+
next_row = 1
5+
6+
while blocks_used + next_row <= number_of_blocks:
7+
blocks_used += next_row
8+
height += 1
9+
next_row += 1
10+
11+
return height

0 commit comments

Comments
 (0)