[Question]
  [
Given an integer \$N\$, you must print a \$N\times N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top left, increasing as you move towards the centre.
## Examples
```
Input => 1
Output => 
0
Input => 2
Output => 
0 1
3 2
Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 
Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18
```
You may output a 2 dimensional array, or a grid of numbers.
Challenge inspired by [Article by Eugene McDonnell](https://www.jsoftware.com/papers/play132.htm)
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the goal is to minimize your source code with answers being scored in bytes.
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 bytes
```
‚Å∏JW;·πöZ+L∆≤∆≤2¬°¬°
```
[Try it online!](https://tio.run/##ASMA3P9qZWxsef//4oG4Slc74bmaWitMxrLGsjLCocKh/8KiR/8xMA "Jelly ‚Äì Try It Online")
A nilad function or full program that takes a number from stdin and returns the 1-based involute of size n √ó n.
### How it works
```
‚Å∏JW;·πöZ+L∆≤∆≤2¬°¬°
‚Å∏                Empty list ([])
          2¬°¬°    Take n from stdin and repeat 2n times starting from the above:
                   Given previous matrix m,
    ·πöZ+L∆≤          Rotate m and add the number of rows of m
 JW;     ∆≤         Prepend a row of 1..(number of rows of m)
```
The involute can be constructed iteratively as follows:
```
Start with m = [] (think of it as 0-row, 0-col matrix)
Repeat 2n times:
    If m has r rows, add r to every cell of m
    Rotate m 90deg clockwise
    Attach 0..r-1 (or 1..r) as a new row at the top of m
```
After every step, the matrix `m` is always an involute for some rectangular size (square at even steps). For example, using 1-based indexing, doing a single step on
```
1 2 3
8 9 4
7 6 5
```
gives
```
 1  2  3
10 11  4
 9 12  5
 8  7  6
```
and then
```
 1  2  3  4
12 13 14  5
11 16 15  6
10  9  8  7
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~12~~ 11 bytes
```
UG1YL-GoQ&P
```
[Try it online!](https://tio.run/##y00syfn/P9TdMNJH1z0/UC3g/39TAA "MATL ‚Äì Try It Online")
MATL (like MATLAB) has a `spiral` matrix which spirals clockwise from the center, so this performs the necessary flips and subtracts the matrix from `N^2`.
~~Probably Luis Mendo knows how to golf this...~~ Thanks to Luis Mendo for ‚àí1 byte.
```
	% Implicit input N
U	% Square
G1YL	% Push the N√óN spiral matrix (S)
	% clockwise from the center, starting at 1
-	% N^2 - S, element-wise
GoQ	% Push mod(N,2)+1
&P	% Flip along that dimension:
	% for odd N, flips the rows; for even N, flips the columns
	% Implicit output
```
[Answer]
# [Python](https://www.python.org), 73 bytes (@ovs)
```
f=lambda n,m=0,p=-1:n*[n]and((*range(m,n),),*zip(*f(2*n-m+p,n,~p)[::-1]))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3PdNscxJzk1ISFfJ0cm0NdApsdQ2t8rSi82IT81I0NLSKEvPSUzVydfI0dTR1tKoyCzS00jSMtPJ0c7ULdPJ06go0o62sdA1jNTWhBqqnFeXnKhQUFGXmlShk5hbkF5VAeVwQSiNNw9AAphzmDgA)
#### Old [Python](https://www.python.org), 74 bytes (@DialFrost)
```
f=lambda n,m=0,p=-1:n and((*range(m,n),),*zip(*f(2*n-m+p,n,~p)[::-1]))or()
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3vdJscxJzk1ISFfJ0cm0NdApsdQ2t8hQS81I0NLSKEvPSUzVydfI0dTR1tKoyCzS00jSMtPJ0c7ULdPJ06go0o62sdA1jNTXzizQ0oSaqpxXl5yoUFBRl5pUoZOYW5BeVQHlcEEojTcPQQBOqHOYQAA)
#### Old [Python](https://www.python.org), 76 bytes
```
f=lambda n,m=0,p=-1:n>m and((*range(m,n),),*zip(*f(2*n-m+p,n,~p)[::-1]))or()
```
-15 by reversing order of recursion.
[Attempt This Online!](https://ato.pxeger.com/run?1=LYwxCgIxEAB7X5HO3biBOys5yL3AH6hF5IweuJslxEILP2ITEP2Tv7G4q4aBYV5fvZdLkvqOfv-5leg2v23018DHIRgh9g2pd20nPZsgA4DNQc4nYBIkJPsYFWyEtRXHKyWhp-Ku61x7QEwZcH4uY05sVPMoxYysKZfZFhMgQtvgnNc68Q8)
#### Old [Python](https://www.python.org), 91 bytes
```
lambda n:g((n*n-1,))
g=lambda*s:(l:=s[0][0])and g((*range(l-len(s),l),),*zip(*s[::-1]))or s
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LY1BCsMgFET3OYW7_i8KcVeEnCTNwpJoA-YrahftVboRSnun3qYBAwOPGR7M6xsf5Raovu1w-dyLleff6M12nQ0j7QCIk1QCsXNDm3nW4PWQx37ag4Zmtms8GXILeOkXgozCo0DBn2sEnketpZoQQ2L5uDjZFDYWY1qpsHWLIZWjdQ1gQfWITa-18Q8)
Builds the spiral from inside to out by recursively rotating 90¬∞ and adding a row on the top.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~18~~ ~~17~~ 16 bytes
```
(‚çâ‚ç≥‚ç®,‚äñ+‚â¢)‚ç£2‚ç£‚éï‚ä§‚ç®‚ç¨
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/@f9qhtQvV/jUe9nY96Nz/qXaHzqGua9qPORZqPehcbAfGj3q2PupYAJR71rvlf@z/tEJCx2QIA "APL (Dyalog Unicode) ‚Äì Try It Online")
Full program. TIO uses `‚çµ` instead of `‚éï` for easier test case demonstration. For the core algorithm, refer to my [Jelly answer](https://codegolf.stackexchange.com/a/241837/78410).
The only additional trick here is the `‚ä§‚ç®‚ç¨`, which is [one of the shortest expressions that give a 0-by-0 matrix (`0 0‚ç¥0`)](https://www.dyalog.com/blog/2021/07/code-golf-generating-empty-arrays/). This one in particular is handy because it doesn't mess up by stranding with the input value.
-1 byte using `‚ç≥‚àò‚â¢ ‚Üí ‚ç≥‚ç®`; the rows are guaranteed to be distinct, so finding indices of items in itself gives the vector of indices for the leading axis.
Also -1 byte by moving `‚çâ` to the end of the train to save a `‚àò`. Add first row to a transposed matrix == Add first column and then transpose it.
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 29 bytes[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)
```
{‚çâ‚åΩ‚àò‚çâ‚àò‚àæ¬¥‚âç¬®‚åΩ(/¬´‚•ä2‚Üï‚Üïùï©+1)‚äî‚åΩ‚Üïùï©‚ãÜ2}
```
[Run online!](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAge+KNieKMveKImOKNieKImOKIvsK04omNwqjijL0oL8Kr4qWKMuKGleKGlfCdlakrMSniipTijL3ihpXwnZWp4ouGMn0KCuKImOKAvzHipYpGwqjijL0xK+KGlTEw)
A port of [Bubbler's Jelly answer](https://codegolf.stackexchange.com/a/241837/64121) comes in at 20 bytes:
```
{(‚äíÀú‚àæ‚çâ‚àò‚åΩ+‚â†)‚çü2‚çüùï©‚Üï0‚Äø0}
```
[Run online!](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAgeyjiipLLnOKIvuKNieKImOKMvSviiaAp4o2fMuKNn/CdlanihpUw4oC/MH0KCuKImOKAvzHipYpGwqjijL0xK+KGlTEw)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~48~~ ~~41~~ 40 bytes
```
Ôº¶‚äóÔºÆ‚âî‚Å∫‚ü¶Ôº•œÖŒª‚üßÔº•‚àßœÖ‚åäœÖ‚Å∫Ôº¨œÖÔº•‚ÆåœÖ¬ßŒºŒªœÖÔº•œÖ‚™´Ôº•Œπ‚óßÔº©ŒªÔº¨‚åàÔº•œÖ‚åàŒΩ 
```
[Try it online!](https://tio.run/##NY29DoMwDIT3PkXE5Eh07MSE2oWqVKhr1SGAgUiJg/KDePs0UOrFd9b5u24StjNCxTgYy@BmQquwh4rm4J9Bt2iBc85K5@RI0Kjg4F2LGULOFP/kbNMl9ZuvJUkdNATOc7YnH0ijn9Lhl3vhgtbh7ktfUY8r6I2zTc4CL06NleThKLgbSbuWiSf6Bw4ersJ5UCl9sGux7qXHy98SP6AZy9IuYrzE86K@ "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Edit: Saved 4 bytes by porting @Bubbler's observation that you can vectorised add the current length of the array to all of its elements on each iteration, 3 bytes by special-casing an empty array to avoid having to perform the first step manually, and 1 byte by golfing my rotation code. Explanation:
```
Ôº¶‚äóÔºÆ
```
Repeat `2n` times.
```
‚âî‚Å∫‚ü¶Ôº•œÖŒª‚üßÔº•‚àßœÖ‚åäœÖ‚Å∫Ôº¨œÖÔº•‚ÆåœÖ¬ßŒºŒªœÖ
```
Rotate the spiral while adding its length to it values and prefix an additional row of numbers from `0` up to its length. (Unfortunately Charcoal won't let me vectorised add the length to the whole matrix at once but fortunately I can at least do it a row at a time as part of the rotation.) Also handle the edge case of the initially empty spiral which produces a zero-length array.
```
Ôº•œÖ‚™´Ôº•Œπ‚óßÔº©ŒªÔº¨‚åàÔº•œÖ‚åàŒΩ 
```
Display the final spiral as a grid.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 35 bytes
```
{(‚çµ*2)-‚åΩ{‚çâ‚åΩ‚çµ,(‚åà/,‚çµ)+‚ç≥‚â¢‚çµ}‚ç£(2√ó‚çµ-1)‚ç™0}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v1rjUe9WLSNN3Uc9e6sf9XYCKaCAjsajng59HSBLU/tR7@ZHnYuAzNpHvYs1jA5PBzJ1DTUf9a4yqP2f9qhtwqPevkddzY961zzq3XJovfGjtomP@qYGBzkDyRAPz@D/aYdWAM2wAAA "APL (Dyalog Unicode) ‚Äì Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 91 bytes
```
f=(n,s=[[n*n-1]],[l]=t=s[0])=>l?f(n,[0,...t].map((_,i)=>s.map(r=>r[i-1]||--l).reverse())):s
```
[Try it online!](https://tio.run/##VY7BasMwEETv@Yq5WVvbwm5OTSLnI3IUpphELgqqZCQ1YJJ8u7tNaKGwMKPZfas9D5chHaOdcu3DySyj4hK@Skpr/@Lrtu8r7XqVVdJNT6pz@5HbuqmklLmXn8MkxHtluZMej6i6qC1zt1tdO5LRXExMRhDRJi1jiBDOZFgotFuWHWvDpiwJ1xVwDD5lhK/MA6OwtOXsj5o55OEZO1iWX@ZJBWekCx@CWT0/L/NQHURRoIQnOQ2nQx5iFhYd3rDHGhv8@DX7V/YtkTwH60WBgh4/31f/d3N4X74B "JavaScript (Node.js) ‚Äì Try It Online")
A port of [loopy walt](https://codegolf.stackexchange.com/users/107561/loopy-walt)'s [Python answer](https://codegolf.stackexchange.com/a/241833/44718). Although I don't really understand what happening.
[Answer]
# [R](https://www.r-project.org/), 78 bytes
```
function(n)matrix(order(cumsum(rep(rep(c(n,1,-n,-1),,x<-2*n-1),n-1:x%/%2))),n)
```
[Try it online!](https://tio.run/##HcdBCoAgEIXhffcQZmIkFGoRdZgwBReOMSV4e8sW7@P90sLeQmH3xMzAmI5HYoUspxdwJd0lgfjrnwMmQ5pJGySqm7Yj9/uxVjUpi/gFtgAGhwC2M3cWbC8 "R ‚Äì Try It Online")
Direct construction of the matrix, no rotations required.
[Answer]
# [R](https://www.r-project.org/), ~~84~~ ~~81~~ 67 bytes
Or **[R](https://www.r-project.org/)>=4.1, 60 bytes** by replacing the word `function` with a `\`.
*Edit: -14 bytes thanks to [@Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe) inspired by [@Bubbler's Jelly answer](https://codegolf.stackexchange.com/a/241837/55372).*
```
function(n){m=t(1)
while(T<n)m=rbind(1:n,(T=nrow(m))+t(m[T:1,]))
m}
```
[Try it online!](https://tio.run/##Fcs7CoAwDADQvSdJsIMVXIq5RTdx8RMsmBRKxUE8e6XL216uTJVv3UpMCoqvUAGH5jnjdUCYFIXyGnUH59VCIM3pAUHsCsgcvLMLopGvclsMQ2NsuB7rDw "R ‚Äì Try It Online")
Uses the common "rotate and add a row on top" approach.
See also [@Giuseppe's direct construction of the matrix](https://codegolf.stackexchange.com/a/241927/55372).
[Answer]
# JavaScript (ES7), ~~¬†111¬†~~ 101 bytes
*Saved 9 bytes thanks to @tsh*
Returns a matrix. The results are 1-indexed.
```
n=>[...Array(n)].map((x=-n/2,y,a)=>a.map(_=>n*n-(i=4*(++x*x>y*y?x:y)**2)+(x>y||-1)*(i**.5+x+y),y+=x))
```
[Try it online!](https://tio.run/##PY7BbsIwEETvfMXesms7bpPCpciueugXcKSosgKhRrCOjBXZKv32FHLoad7MHGZObnTXLvoh1Rz2h6k3Exu71Vq/x@gKMu30xQ2I2dT81KqiHBnr5uzLWBZcozdLgVJmkW0R5S2/FhKiJYl3f7vVDQn0QuiVzLKQKtJkomm9bRS0ClYKmued7kP8cN03MhgLPwuALvA1nA/6HI7Y32/Mi/HRxhnHB446hU2Kno9IenD7TXIx4QuRPgXPWEH1j59cEUiYdfFL0x8 "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Julia](http://julialang.org/), 46 bytes
```
m\n=[1:n n.+rotl90(m')]'
!n=[n<2||!~-n\~-n\n;]
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/Pzcmzzba0CpPIU9Puyi/JMfSQCNXXTNWnUsRKJ5nY1RTo1inmxcDwnnWsf/T8osUMhUy8xQMrQwNuBSAICWzuCAnsVJDMVMTzC8oyswrycnT0ORKzUv5DwA "Julia 1.0 ‚Äì Try It Online")
the simple rotate and add row, with some trickery with `'` (transpose)   
starts with 1
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~¬†34 33¬†~~ 32 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
I would have thought Jelly would be better at this, maybe a more mathematical approach will triumph?
```
≈íM·∏¢·∏¢
+√æ`¬¨Z·πö$·πõ¬¨√á$¬¶‚Ç¨√á¬¶‚Äò…º$·∏£√á»¶∆ä?∆¨»¶∆á·πÇ
```
A monadic Link accepting a positive integer that yields a list of lists of positive integers (top-left `1` option).
**[Try it online!](https://tio.run/##y0rNyan8///oJN@HOxYBEZf24X0Jh9ZEPdw5S@XhztmH1hxuVzm07FETkAZSDTNO7lF5uGPx4fYTy4512R9bA6TaH@5s@n@43f3/f0MDAA "Jelly ‚Äì Try It Online")**
### How?
Start with an \$N\times N\$ table of zeros, then repeatedly either fill in the next number in the first zero of the first row that contains a maximal value, unless that row is filled in which case rotate. This process terminates with a full table but rotated further than we want, so we collect all the states along the way then pick the one we need out (using `»¶∆á·πÇ`).
```
≈íM·∏¢·∏¢ - Helper Link: list of list of integers (current state)
≈íM   - multidimensional indices of maximal elements
  ·∏¢  - head
   ·∏¢ - head -> row index containing the maximum value
+√æ`¬¨Z·πö$·πõ¬¨√á$¬¶‚Ç¨√á¬¶‚Äò…º$·∏£√á»¶∆ä?∆¨»¶∆á·πÇ - Link: positive integer, N
+√æ`                         - [1..N] addition table with [1..N]
   ¬¨                        - logical NOT -> N√óN table of zeros
                       ∆¨    - collect inputs while distinct applying:
                      ?     -   if...
                     ∆ä      -   ...condition: last three links as a monad:
                   √á        -     call our helper link
                  ·∏£         -     head (the current state) to that index
                    »¶       -     all truthy when flattened?
      $                     -   ...then: last two links as a monad:
    Z                       -     transpose
     ·πö                      -     reverse
                                  - this rotates when we've finished a row
                 $          -   ...else: last two links as a monad:
                …º           -     apply to the register (initially 0) & yield:
               ‚Äò            -       increment
              ¬¶             -     sparse application...
             √á              -     ...to indices: call our helper link
            ‚Ç¨               -     ...apply: for each:
           ¬¶                -       sparse application...
          $                 -       ...to indices: last two links as a monad:
        ¬¨                   -         logical NOT (vectorises)
         √á                  -         call our helper link
       ·πõ                    -       ...apply: the incremented register value
                         ∆á  - filter keep those for which:
                        »¶   -   all truthy when flattened?
                          ·πÇ - minimum (of the rotate tables we have left)
```
---
Another approach, but even more lengthy at 39:
```
R¬µ·πöƒñm‚Ç¨0F;‚±Æ"·∏ä·πö‚Äô$·πñ·πö4∆≠¬≥‚Äô·∏§¬§√ê¬°U√êe·∫éI∆á≈í·π¨‚Ç¨√ó"J$S
```
[Try this one](https://tio.run/##y0rNyan8/z/o0NaHO2cdmZb7qGmNgZv1o43rlB7u6AIKPWqYqfJw5zQgy@TY2kObgdyHO5YcWnJ4wqGFoYcnpD7c1ed5rP3opIc71wB1Hp6u5KUS/P9wu/v//4YGAA "Jelly ‚Äì Try It Online")
This one works by building a list of the two-dimensional indices ordered by their final value then composing the table by adding up tables that are all zeros except the bottom-rightmost entry which is the number we want there in the end.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
¬ØI¬∑FƒÅU√∏√≠¬¨g+X≈°
```
1-based.
Port of [*@Bubbler*'s Jelly answer](https://codegolf.stackexchange.com/a/241837/52210), so make sure to upvote him as well!
[Try it online](https://tio.run/##AR8A4P9vc2FiaWX//8KvScK3RsSBVcO4w63CrGcrWMWh//81) or [verify all test cases](https://tio.run/##yy9OTMpM/R/ipuSZV1BaYqWgZO@n8//Qer9D292ONIYe3nF47aE16doRRxf@r@VSckwuKU3MUcgvLYGqteVSCihKLSmp1C0oyswrSU1ByOlwRaXbhZ3bem5r5OFdQZGPOnqDar0OLas9tFuH69A2@/8A).
**Explanation:**
```
¬Ø             # Start with an empty list []
 I¬∑           # Push the input and double it
   F          # Pop and loop that many times:
    ƒÅ         #  Push a list in the range [1,length] (without popping the matrix)
     U        #  Pop and store this list in variable `X`
      √∏√≠      #  Rotate the matrix 90 degrees clockwise:
      √∏       #   Zip/transpose; swapping rows/columns
       √≠      #   Reverse each row
        ¬¨     #  Push the first row (without popping the matrix)
         g    #  Pop and push its length
          +   #  Add that to each value in the matrix
           X≈° #  Prepend `X` as first row
              # (after the loop, the resulting matrix is output implicitly)
```
[Answer]
# [R](https://www.r-project.org/), ~~187~~ ~~183~~ 151 bytes
```
function(n){w=which
X=diag(0,n)
X[n,]=m=n:1
while(!min(X)){i=w(!X)[1]
j=w(!!X[-1:-i])
X[i-1+1:j]=max(X)+j:1
X=t(X)[m,]}
`if`(n%%2,t(t(X)[m,])[m,],X)-1}
```
[Try it online!](https://tio.run/##NYxNCoMwEIX3cwsXwgQTaIR2Icw9AiGg2KaO1BGKxULx7GlS6Obj8f6eKVKKLxk3XgVFfWCnfeJxAkdXHu540qLAedGBFpLOQk4fN6wWFnQq95l2rJzyNsBcZOW8sZ3hUGZsbGO7OW@Hd643cz5wtGXpFx0O6Dn2KHXd6g3/7g/aKWOPFNEqiNgWnAsuKn0B "R ‚Äì Try It Online")
A clumsier version of rotate and fill!
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 108 bytes
```
n=>[...Array(n)].map((_,Y,a)=>a.map(g=(y=Y,x,_,s=n)=>y?--s-x?s-y?x?s*4+g(y-1,x-1,_,s-1):4*s-y:3*s-x:s+y:x));
```
[Try it online!](https://tio.run/##VU/BasMwDL33K3SL1NhmWXtpUifsG3YqZRTTJsEls0PsjZjRb8@0lg12sN7T83sSuppPE86THaN0/tIunV6cro9KqZdpMgkdval3MyKexEEY0rW5t73GpA9iFicRtGM5NVIGOTdBpobrepv3mGQhZn7skQWV2zV/lhuucxnyVM5E1dL5CXBoI1jQUFQMe8YnJnlO8LUCOHsXIviPyIYOLVWs/aUSi2xOsAfL8Jt5pPzQqsH3yNljepzhQNeAWQY5OFKjubxGM0W0UMMOGthACT98w/yZeUGkrt46zCCj@@bb6v9sFm/LNw "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Factor](https://factorcode.org/) + `math.matrices`, ~~82~~ 79 bytes
```
[ 2 * { } [ dup length [ m+n flip [ reverse ] map ] keep iota prefix ] repeat ]
```
[Try it online!](https://tio.run/##HY07DsIwFAR7TrE1iAgo4QCIhgZRRSlM2AQrjmOeXxAfcXbj0IxGW8w2ptZB0vl0OO636I3e0FE83d@LDLE1IyLvI/1kLT3FOPs2agcfEYSqryDWK3az2XqVSmwwxwdflLiOAY6@zd0S/cKjcTZkFT4okajyT8jsyAA7qJl6jX3mSRhoFFWqjXOItg@OSzUXxyL9AA "Factor ‚Äì Try It Online")
Port of @Bubbler's excellent [Jelly answer](https://codegolf.stackexchange.com/a/241837/97916).
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 52 bytes
-8 bytes thanks to @att.
```
Nest[Join[{l=0;l++&/@#},Reverse@#Ôèá+l]&,{{}},2#-1]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@98vtbgk2is/My@6OsfWwDpHW1tN30G5VicotSy1qDjVQfl9f7t2TqyaTnV1ba2OkbKuYaza/4CizLySaGUFXTuFtGjl2FgFNQV9B4VqQx0FIx0FUx0FQ4Pa/wA "Wolfram Language (Mathematica) ‚Äì Try It Online")
]