From b993a57af82d325af6ab37b42917fc15d45d0a3c Mon Sep 17 00:00:00 2001 From: anilguler Date: Tue, 24 Mar 2026 17:31:07 +0300 Subject: [PATCH 1/3] Create pyramid_anil_guler.py --- Week03/pyramid_anil_guler.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Week03/pyramid_anil_guler.py diff --git a/Week03/pyramid_anil_guler.py b/Week03/pyramid_anil_guler.py new file mode 100644 index 00000000..5e872cde --- /dev/null +++ b/Week03/pyramid_anil_guler.py @@ -0,0 +1,9 @@ +def calculate_pyramid(blocks): + height = 0 + total_blocks = 0 + + while total_blocks + (height + 1) <= blocks: + height += 1 + total_blocks += height + + return height From ad6714c10bb7cb232355c94a53b5f72d869496b5 Mon Sep 17 00:00:00 2001 From: anilguler Date: Tue, 24 Mar 2026 17:35:04 +0300 Subject: [PATCH 2/3] Update pyramid_anil_guler.py --- Week03/pyramid_anil_guler.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Week03/pyramid_anil_guler.py b/Week03/pyramid_anil_guler.py index 5e872cde..62ef0ed0 100644 --- a/Week03/pyramid_anil_guler.py +++ b/Week03/pyramid_anil_guler.py @@ -1,9 +1,6 @@ def calculate_pyramid(blocks): - height = 0 - total_blocks = 0 - - while total_blocks + (height + 1) <= blocks: + height = 0 + while blocks >= height + 1: height += 1 - total_blocks += height - - return height + blocks -= height + return height From b8883604b459133e9f0cf37ac8449a9de1606d96 Mon Sep 17 00:00:00 2001 From: anilguler Date: Tue, 24 Mar 2026 17:36:22 +0300 Subject: [PATCH 3/3] Update pyramid_anil_guler.py --- Week03/pyramid_anil_guler.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Week03/pyramid_anil_guler.py b/Week03/pyramid_anil_guler.py index 62ef0ed0..fbb03673 100644 --- a/Week03/pyramid_anil_guler.py +++ b/Week03/pyramid_anil_guler.py @@ -1,6 +1,10 @@ -def calculate_pyramid(blocks): +def calculate_pyramid_height(blocks): height = 0 - while blocks >= height + 1: + required_blocks = 1 + + while blocks >= required_blocks: + blocks -= required_blocks height += 1 - blocks -= height + required_blocks += 1 + return height