Skip to content

Commit 8b98eff

Browse files
authored
Merge branch 'canbula:master' into master
2 parents d884fc5 + 2c737e9 commit 8b98eff

27 files changed

+669
-0
lines changed

Week02/types_mustafa_ceylan.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
my_int = 35
2+
my_float = 21.35
3+
my_bool = False
4+
my_complex= 14j
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
3+
i=1
4+
while number_of_blocks>0 :
5+
number_of_blocks-=i
6+
i+=1
7+
height+=1
8+
if(number_of_blocks -i < 0):
9+
break
10+
return height

Week03/pyramid_bilal_ayakdas.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def calculate_pyramid_height(number_of_blocks: int) -> int:
2+
"""
3+
Calculate the height of a pyramid given the number of blocks.
4+
:param number_of_blocks: The total number of blocks available to build the pyramid.
5+
:type number_of_blocks: int
6+
:raises ValueError: If the number of blocks is less than or equal to 0.
7+
:return: The maximum height of the pyramid that can be built.
8+
:rtype: int
9+
"""
10+
if number_of_blocks <= 0:
11+
raise ValueError("Number of blocks must be greater than 0")
12+
13+
height, layer = 0, 1
14+
15+
while number_of_blocks >= layer:
16+
number_of_blocks -= layer
17+
height += 1
18+
layer += 1
19+
20+
return height
21+

Week03/pyramid_cagan_atan.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 : int) -> int:
2+
if number_of_blocks < 0:
3+
raise ValueError("The number of blocks must be a non-negative integer.")
4+
height = 0
5+
while number_of_blocks > 0:
6+
height += 1
7+
number_of_blocks -= height
8+
# If the number of blocks is negative (the layer is missing blocks), the height is decremented by 1.
9+
if number_of_blocks < 0:
10+
height -= 1
11+
return height

Week03/pyramid_enes_dogan.py

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

Week03/pyramid_eren_malkoc.py

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

Week03/pyramid_furkan_bulut.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
"""
3+
Calculate the height of a pyramid that can be built with a given number of blocks.
4+
5+
The function determines how many complete layers (height) can be formed
6+
using the provided number of blocks. Each layer requires a number of blocks
7+
equal to the layer number (1 block for the first layer, 2 blocks for the
8+
second layer, etc.).
9+
10+
:param number_of_blocks: The total number of blocks available to build the pyramid.
11+
:type number_of_blocks: int
12+
:return: The maximum height of the pyramid that can be built.
13+
:rtype: int
14+
15+
:raises ValueError: If `number_of_blocks` is less than 0.
16+
17+
Example:
18+
19+
calculate_pyramid_height(6)
20+
3
21+
calculate_pyramid_height(20)
22+
5
23+
"""
24+
if number_of_blocks < 0:
25+
raise ValueError("Number of blocks must be non-negative.")
26+
27+
height_of_pyramid = 0
28+
block_counter = 0
29+
30+
while number_of_blocks >= (block_counter + (height_of_pyramid + 1)):
31+
block_counter += height_of_pyramid + 1
32+
height_of_pyramid += 1
33+
34+
return height_of_pyramid
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
3+
i = 1
4+
while number_of_blocks > 0:
5+
number_of_blocks -= i
6+
i += 1
7+
height += 1
8+
if number_of_blocks - i < 0:
9+
break
10+
return height

Week03/pyramid_ipek_naz_sipahi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
height = 0
3+
total_blocks = 0 # Total number of blocks used so far
4+
while total_blocks + (height + 1) <= number_of_blocks:
5+
height += 1
6+
total_blocks += height # Add the number of blocks in the new level to the total
7+
return height

Week03/pyramid_mert_durgun.py

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

0 commit comments

Comments
 (0)