Skip to main content
1 of 6
Sp3000
  • 62.3k
  • 13
  • 117
  • 292

#Python 2, 89 named / 87 unnamed

f=lambda n:"\n".join([" "+n/2*4*"_",(" /\\ "*n)[:2+2*n],("/__\\"*n)[:2*n-~(n%2)]][n<2:]) 

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 
Sp3000
  • 62.3k
  • 13
  • 117
  • 292