Skip to main content
added 48 characters in body
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

JavaScript (Node.js), 62 6060 58 bytes

f=(n,i=0i=n,s='')=>i<n=>i?[...Array(n)].map((_,j)=>f(n,i+1i-1,s+j)):s

Try it online! OutputTry it online! Output is 0-indexed. Edit: Saved 2 bytes thanks to @JoKing and a further 2 bytes thanks to @Arnauld.

JavaScript (Node.js), 62 60 bytes

f=(n,i=0,s='')=>i<n?[...Array(n)].map((_,j)=>f(n,i+1,s+j)):s

Try it online! Output is 0-indexed. Edit: Saved 2 bytes thanks to @JoKing.

JavaScript (Node.js), 62 60 58 bytes

f=(n,i=n,s='')=>i?[...Array(n)].map((_,j)=>f(n,i-1,s+j)):s

Try it online! Output is 0-indexed. Edit: Saved 2 bytes thanks to @JoKing and a further 2 bytes thanks to @Arnauld.

added 43 characters in body
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

JavaScript (Node.js), 6262 60 bytes

f=(n,i=0,s='')=>i<n?[...Array(n)].map((_,j)=>f(n,i+1,s+j)):[s]s

Try it online!Try it online! Output is 0-indexed. Edit: Saved 2 bytes thanks to @JoKing.

JavaScript (Node.js), 62 bytes

f=(n,i=0,s='')=>i<n?[...Array(n)].map((_,j)=>f(n,i+1,s+j)):[s]

Try it online! Output is 0-indexed.

JavaScript (Node.js), 62 60 bytes

f=(n,i=0,s='')=>i<n?[...Array(n)].map((_,j)=>f(n,i+1,s+j)):s

Try it online! Output is 0-indexed. Edit: Saved 2 bytes thanks to @JoKing.

Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

JavaScript (Node.js), 62 bytes

f=(n,i=0,s='')=>i<n?[...Array(n)].map((_,j)=>f(n,i+1,s+j)):[s]

Try it online! Output is 0-indexed.