Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
n,d=input() c='|\/'[d] i=n while i:print' '*(n-i*d)+c,['i%2*c or' ',c][i%2],c;i-=1
Try it online!Try it online!
Takes [1,0,-1] for [north-west, north, north-east]
[1,0,-1]
[north-west, north, north-east]
-1 byte, thanks to Neil
n,d=input() c='|\/'[d] i=n while i:print' '*(n-i*d)+c,[' ',c][i%2],c;i-=1
Try it online!
n,d=input() c='|\/'[d] i=n while i:print' '*(n-i*d)+c,i%2*c or' ',c;i-=1
n,d=input() c='|\/'[d] fori=n while i in range(n):print' '*(n+i*dn-i*d)+c,[' ',c][(n-i)%2]c][i%2],cc;i-=1
Takes d as [1,0,-1] for left[north-west,center north,right north-east]
left[north-west,center north,right north-east]
n,d=input() c='|\/'[d] for i in range(n):print' '*(n+i*d)+c,[' ',c][(n-i)%2],c
Takes d as [1,0,-1] for left,center,right
left,center,right
n,d=input() c='|c='|\/\\'[d]'[d] for i in range(n):print' '*(n-i*dn+i*d)+c,[' ',c][(n-i)%2],c
n,d=input() c='|/\\'[d] for i in range(n):print' '*(n-i*d)+c,[' ',c][(n-i)%2],c