From f22823201c74c2b48c36ea6b5184ce8a5f1751ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Turhan=20G=C3=BCnd=C3=BCzo=C4=9Flu?= <220315031@ogr.cbu.edu.tr> Date: Tue, 7 Apr 2026 11:47:27 +0300 Subject: [PATCH] Add function to calculate pyramid height from blocks --- Week03/pyramid_turhan_gunduzoglu.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Week03/pyramid_turhan_gunduzoglu.py diff --git a/Week03/pyramid_turhan_gunduzoglu.py b/Week03/pyramid_turhan_gunduzoglu.py new file mode 100644 index 00000000..fdd58c46 --- /dev/null +++ b/Week03/pyramid_turhan_gunduzoglu.py @@ -0,0 +1,9 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + used_blocks = 0 + + while used_blocks + (height + 1) <= number_of_blocks: + height += 1 + used_blocks += height + + return height