From e88db656691bf1317dbf6b98840edabe44cabe20 Mon Sep 17 00:00:00 2001 From: Burakcan Aksoy <147622289+burakcnaksy0@users.noreply.github.com> Date: Thu, 8 Jan 2026 05:29:45 +0300 Subject: [PATCH] Create pyramid_first_last.py --- Week03/pyramid_first_last.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Week03/pyramid_first_last.py diff --git a/Week03/pyramid_first_last.py b/Week03/pyramid_first_last.py new file mode 100644 index 00000000..4f749892 --- /dev/null +++ b/Week03/pyramid_first_last.py @@ -0,0 +1,18 @@ +def calculate_pyramid_height(number_of_blocks): + """ + This function calculates the height of a pyramid + given the number of blocks available. + + A pyramid has 1 block at top, 2 blocks in second row, + 3 blocks in third row, etc. + + Returns the maximum height that can be built. + """ + height = 0 + total_blocks_used = 0 + + while total_blocks_used + (height + 1) <= number_of_blocks: + height += 1 + total_blocks_used += height + + return height