Skip to content

Commit b9589ea

Browse files
authored
Merge pull request #972 from Lesyk01/patch-4
Add function to calculate pyramid height from blocks
2 parents 57f758d + b1b6644 commit b9589ea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Week03/pyramid_oleksii_rak.py

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

0 commit comments

Comments
 (0)