From c77b851196530a5ee381f1bdc5222e40546ba5e0 Mon Sep 17 00:00:00 2001 From: Almira <161606553+almirakeles@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:19:24 +0300 Subject: [PATCH] Add function to calculate pyramid height Implement function to calculate pyramid height based on number of blocks. --- Week03/pyramid_almira_keles.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Week03/pyramid_almira_keles.py diff --git a/Week03/pyramid_almira_keles.py b/Week03/pyramid_almira_keles.py new file mode 100644 index 00000000..f51c80ce --- /dev/null +++ b/Week03/pyramid_almira_keles.py @@ -0,0 +1,18 @@ +from __future__ import annotations + +def calculate_pyramid_height(number_of_blocks: int) -> int: + + if number_of_blocks <= 0: + return 0 + + + h = 0 + used = 0 + next_row = 1 + + while used + next_row <= number_of_blocks: + used += next_row + h += 1 + next_row += 1 + + return h