Skip to main content
6 of 6
Commonmark migration

JavaScript (ES8),  90 87  85 bytes

Takes input as (direction)(length). Expects \$0\$ for North-West, \$1\$ for North or \$2\$ for North-East.

d=>g=(n,w=n)=>n?(c='/|\\'[d]).padStart([n--,,w-n][d])+` ${n&1?' ':c} ${c}
`+g(n,w):''

Try it online!


JavaScript (ES6), 90 bytes

This one draws the output character by character with a little more maths instead of the .padStart() method.

Takes input as (direction)(length). Expects \$1\$ for North-West, \$2\$ for North or \$3\$ for North-East.

d=>n=>(g=x=>y?` /|\\
`[x+5?17+y%2*4>>--x+5-[,n+1-y,n,y][d]&1&&d:(x=n,y--,4)]+g(x):'')(y=n)

Try it online!

Arnauld
  • 197.7k
  • 20
  • 179
  • 650