DEV Community

Discussion on: Daily Challenge #52 - Building a Pyramid

Collapse
 
aadibajpai profile image
Aadi Bajpai

Python one-liner yet again :)

>>> pyramid = lambda x: print('\n'.join(f'{a}' for a in [' '*(((2*(x-i)-1)//2))+'*'*(i*2+1) for i in range(x)]))
>>> pyramid(5)
    *
   ***
  *****
 *******
*********
>>> pyramid(4)
   *
  ***
 *****
*******
>>> pyramid(1)
*
Collapse
 
devparkk profile image
Dev Prakash

Impeccable