Building Pyramids

This commit is contained in:
2023-06-26 15:18:13 +02:00
parent fedb5b3de2
commit 64b6244a14

9
pyramids.py Normal file
View File

@@ -0,0 +1,9 @@
blocks_available = int(input())
total_blocks_needed = 0
i = 0
while True:
i += 1
total_blocks_needed += (i * 2 - 1) ** 2
if total_blocks_needed > blocks_available:
print(i - 1)
exit()