From 0b9a7c89a402bee014edbbce238b8e594b08a443 Mon Sep 17 00:00:00 2001 From: Batuhan Keskin <121479880+batyou0ne@users.noreply.github.com> Date: Wed, 28 Oct 2026 21:03:25 +0300 Subject: [PATCH] Add function to calculate pyramid height from blocks --- Week03/pyramid_batuhan_keskin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Week03/pyramid_batuhan_keskin.py diff --git a/Week03/pyramid_batuhan_keskin.py b/Week03/pyramid_batuhan_keskin.py new file mode 100644 index 00000000..c1f013d7 --- /dev/null +++ b/Week03/pyramid_batuhan_keskin.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + needed_blocks = 1 + + while number_of_blocks >= needed_blocks: + number_of_blocks -= needed_blocks + height += 1 + needed_blocks += 1 + + return height