From ae891c0b79839d11798a43af334ff035dd210986 Mon Sep 17 00:00:00 2001 From: GulsumCey1an Date: Fri, 6 Nov 2026 01:28:32 +0300 Subject: [PATCH] Add function to calculate pyramid height Implement a function to calculate the height of a pyramid based on the number of blocks. --- Week03/pyramid_gulsum_ceylan.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Week03/pyramid_gulsum_ceylan.py diff --git a/Week03/pyramid_gulsum_ceylan.py b/Week03/pyramid_gulsum_ceylan.py new file mode 100644 index 00000000..779c3e4d --- /dev/null +++ b/Week03/pyramid_gulsum_ceylan.py @@ -0,0 +1,11 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + blocks_used = 0 + next_row = 1 + + while blocks_used + next_row <= number_of_blocks: + blocks_used += next_row + height += 1 + next_row += 1 + + return height