Skip to main content
Commonmark migration
Source Link

#JavaScript (ES8),  90 87  85 bytes

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

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!

#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!

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!

added an ES6 version
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

#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!

#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 (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!

minor update
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

#JavaScript (ES8),  90 87  85 bytes

Takes input as (direction)(length). Expects \$0\$ for diagonalNorth-West, \$1\$ for straightNorth or \$2\$ for antiNorth-diagonalEast.

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

Try it online!Try it online!

#JavaScript (ES8),  90 87  85 bytes

Takes input as (direction)(length). Expects \$0\$ for diagonal, \$1\$ for straight or \$2\$ for anti-diagonal.

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

Try it online!

#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!

saved 2 bytes
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
saved 3 bytes
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading