From b6db8ea77dfa4c3a554286316f8f3c7209e19f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dilara=20A=C4=9Fa=C3=A7?= <162055171+dilaraagac@users.noreply.github.com> Date: Mon, 5 Jan 2026 10:17:43 +0300 Subject: [PATCH] Implement pyramid height calculation function Adds a function to calculate the height of a pyramid based on the number of blocks. --- Week03/pyramid_dilara_agac.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Week03/pyramid_dilara_agac.py diff --git a/Week03/pyramid_dilara_agac.py b/Week03/pyramid_dilara_agac.py new file mode 100644 index 00000000..85b2233a --- /dev/null +++ b/Week03/pyramid_dilara_agac.py @@ -0,0 +1,13 @@ +def calculate_pyramid_height(number_of_blocks): + """ + This function calculates the height of a pyramid + that can be built with the given number of blocks. + """ + height = 0 + used_blocks = 0 + + while used_blocks + (height + 1) <= number_of_blocks: + height += 1 + used_blocks += height + + return height