Skip to content

Commit 09aac0c

Browse files
authored
Add function to calculate pyramid height from blocks
1 parent a553d12 commit 09aac0c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎Week03/pyramid_efesamil_sarigul.py‎

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

0 commit comments

Comments
 (0)