[Challenge] Pyramid building | Sololearn: Learn to code for FREE!

+12

[Challenge] Pyramid building

You get a input value i, which stands for the bricks you have. Your challenge is to return a value l which stands for the height of the highest pyramid you can build with the given bricks. Only restriction is that for every stone higher than the ones on the ground there must be 2 on his bottom. eg. input ==> 6 pyramid: # # # # # # output ==> 3 if you have any question or solutions let me know in the comments and leave a like if liked the challenge :) happy coding

10/8/2017 3:31:21 PM

Chrizzhigh

20 Answers

New Answer

+17

👉//try it buddy , & if possible can it be marked as best 👈 https://code.sololearn.com/c07WRDN8thIi/?ref=app

+16

seems like i need to modify the code ☺ to handle this edit ::: try my code now ... its modified now😊😊

+12

u made 4 # in place of 3 #

+10

if you haven't the right number of bricks you can even build more then one wall... 🐍 https://code.sololearn.com/cz0na4iuyJa4/?ref=app

+10

My try https://code.sololearn.com/cB49RlJzon6k/?ref=app

+9

Here is a 2-liner https://code.sololearn.com/cBi7yVJynXRN/#py

+9

Here's an upgraded version, more user-friendly https://code.sololearn.com/c40eXap0ZVx9/?ref=app

+7

@Yash Thatte try my code... 😊

+7

marking thread

+7

Thanks M Abrate for following me !!!

+6

I hope I mathed correctly! https://code.sololearn.com/W6XtGA3sWq8D/?ref=app

+6

https://code.sololearn.com/cFSpD3AN7d6k/?ref=app

+5

One linear https://code.sololearn.com/c5s49FO31k1C/?ref=app

+5

@GAURAV AGRAWAL just to demonstrate that the leftovers can be placed anywhere and the hight wont increase until its a perfect pyramid again =) but thanks for checking

+5

On Python https://code.sololearn.com/c07GajCnMZNu

+4

Ok to clarify : you dont have to build perfect pyramids, you only have to make them the highest without violating the constrains... so for the asked input 7 input ==> 7 pyramid: # ## #### output ==> 3 so most programs are correct by still building perfect pyramids and having left overs... maybe a new challenge will come soon where it is different ;)

+3

I know mine doesn't strictly adhere to the rules, but I did it this way so that it would line up. I do, however, have a version that satisfies your rules. https://code.sololearn.com/cPcMEXNjSkEu/#cs