Skip to content

Commit b152bf6

Browse files
authored
Merge pull request #944 from beytullaharslannn/patch-2
Create pyramid_beytullah_arslan.py
2 parents cc5d01b + f0b036e commit b152bf6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Week03/pyramid_beytullah_arslan.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
if number_of_blocks <= 0:
3+
return 0
4+
height = int((-1 + (1 + 8 * number_of_blocks) ** 0.5) / 2)
5+
return height #O(1)
6+
7+
# def calculate_pyramid_height(number_of_blocks):
8+
# number_of_blocks = 1
9+
# while True:
10+
# if blocks < height:
11+
# height = height-1
12+
# break
13+
# blocks = blocks - height
14+
# height += 1
15+
# return height O(n)

0 commit comments

Comments
 (0)