Skip to main content
added 4 characters in body
Source Link
l4m2
  • 28.5k
  • 2
  • 25
  • 104

JavaScript (Node.js), 149148 bytes

n=>f=(L=n<0&&n,R=n>0&&n)=>[...Array(r=3**(n>0?n:-n))].map(_=>((j++).toString(3)+1).indexOf(1)>(L>0?L:-L)?'_':' ',j=r+r).join``+`\n$join``+`
${L++<R?f(L,R):''}`

Try it online!

No recursiveTry it online!

JavaScript (Node.js), 149 bytes

n=>f=(L=n<0&&n,R=n>0&&n)=>[...Array(r=3**(n>0?n:-n))].map(_=>((j++).toString(3)+1).indexOf(1)>(L>0?L:-L)?'_':' ',j=r+r).join``+`\n${L++<R?f(L,R):''}`

Try it online!

No recursive

JavaScript (Node.js), 148 bytes

n=>f=(L=n<0&&n,R=n>0&&n)=>[...Array(r=3**(n>0?n:-n))].map(_=>((j++).toString(3)+1).indexOf(1)>(L>0?L:-L)?'_':' ',j=r+r).join``+`
${L++<R?f(L,R):''}`

Try it online!

Source Link
l4m2
  • 28.5k
  • 2
  • 25
  • 104

JavaScript (Node.js), 149 bytes

n=>f=(L=n<0&&n,R=n>0&&n)=>[...Array(r=3**(n>0?n:-n))].map(_=>((j++).toString(3)+1).indexOf(1)>(L>0?L:-L)?'_':' ',j=r+r).join``+`\n${L++<R?f(L,R):''}`

Try it online!

No recursive