From 76172212f94e91907eeb0184bc0f914187a386d7 Mon Sep 17 00:00:00 2001 From: Yusuf003007 Date: Mon, 12 Oct 2026 22:54:59 +0300 Subject: [PATCH] Add function to calculate pyramid height from blocks --- Week03/pyramid_yusuf_baris.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Week03/pyramid_yusuf_baris.py diff --git a/Week03/pyramid_yusuf_baris.py b/Week03/pyramid_yusuf_baris.py new file mode 100644 index 000000000..e372fe543 --- /dev/null +++ b/Week03/pyramid_yusuf_baris.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + blocks_used = 0 + while blocks_used + (height + 1) ** 2 <= number_of_blocks: + height += 1 + blocks_used += height ** 2 + return height + + +print(calculate_pyramid_height(14))