[Question]
  [
[Related](https://codegolf.stackexchange.com/questions/103902/wrap-a-seasonal-present)
A room, in the context of this challenge, is a multidimensional array where the elements on the "outside" are `1`, to represent the walls, and all the other elements are `0` (empty space inside the room)
Here's a 1D room with size 5:
```
[1,0,0,0,1]
```
And here's a 2D room with size 6x4:
```
[[1,1,1,1],
 [1,0,0,1],
 [1,0,0,1],
 [1,0,0,1],
 [1,0,0,1],
 [1,1,1,1]]
```
It's 6x4 and not 4x6 because the list has length 6 at depth 1, and length 4 at depth 2.
Or a 4x4x4 room (imagine each 4x4 sub-array as a 2D slice of the 3D room):
```
[[[1,1,1,1],
  [1,1,1,1],
  [1,1,1,1],
  [1,1,1,1]],
 [[1,1,1,1],
  [1,0,0,1],
  [1,0,0,1],
  [1,1,1,1]],
 [[1,1,1,1],
  [1,0,0,1],
  [1,0,0,1],
  [1,1,1,1]],
 [[1,1,1,1],
  [1,1,1,1],
  [1,1,1,1],
  [1,1,1,1]]]
```
A room can be recursively defined by starting with `0` and replacing each `0` with `[1,0,0,...,0,1]` and each 1 with `[1,1,...,1,1]`, each to the appropriate length and depth.
Your challenge is to take a list of integers and output a room with those dimensions. Dimensions will always be \$ >1 \$. A dimension value of 2 means no space inside, so if there's a 2 the whole thing will be `1`s.
You may use any two consistent values instead of `0` and `1` to represent space and wall.
Output may be as a flattened string, e.g. [3,4] => `111110011111`.
You may take the coordinate list reversed (inside out).
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins!
# Testcases
```
[3] => [1,0,1]
[2,2,2,2,2] => [ [ [ [ [1,1], [1,1] ], [ [1,1], [1,1] ] ], [ [ [1,1], [1,1] ], [ [1,1], [1,1] ] ] ], [ [ [ [1,1], [1,1] ], [ [1,1], [1,1] ] ], [ [ [1,1], [1,1] ], [ [1,1], [1,1] ] ] ] ]
[4,4,4] => [ [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1] ], [ [1,1,1,1], [1,0,0,1], [1,0,0,1], [1,1,1,1] ], [ [1,1,1,1], [1,0,0,1], [1,0,0,1], [1,1,1,1] ], [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1] ] ]
[5,6] => [ [1,1,1,1,1,1], [1,0,0,0,0,1], [1,0,0,0,0,1], [1,0,0,0,0,1], [1,1,1,1,1,1] ]
[3,19] => [ [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1], [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] ]
[12] => [1,0,0,0,0,0,0,0,0,0,0,1]
```
Thanks to golden\_bat and pxeger for clarifying and fixing this challenge.
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
R%)Ịoþ/
```
A monadic Link that accepts the dimensions as a list of positive integers ordered by depth descending (like the examples in the question) and yields the room as a multi-dimensional list of `1`s and `0`s.
**[Try it online!](https://tio.run/##y0rNyan8/z9IVfPh7q78w/v0////H22iY6pjFgsA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8/z9IVfPh7q78w/v0/x9uf9S05uikhztnAOmsR437uLj@/482jtWJNtIBQyDLRAcIgbSpjhmQNLTUAUkbGsUCAA "Jelly – Try It Online")
### How?
```
R%)Ịoþ/ - Link: list of positive integers, Sizes
  )     - for each (size in Sizes):
R       -   range (size)  -> [1,2,3,...,size]
 %      -   modulo (size) -> [1,2,3,...,0]
   Ị    - insignificant?  -> [...,[1,0,0,...,1],...]
      / - reduce by:
     þ  -   make a table using:
    o   -     logical OR (vectorises)
```
[Answer]
# [APL(Dyalog Unicode)](https://dyalog.com), 11 bytes [SBCS](https://github.com/abrudz/SBCS)
```
⊢↑1∘-↑-∘2⍴≡
```
[Try it on APLgolf!](https://razetime.github.io/APLgolf/?h=AwA&c=e9S16FHbRMNHHTN0gbQukDZ61LvlUedCAA&f=S1PQMeZS19XVVedKUzDSAUM430QHCOE8Ux0zONvQEkmbjqGRAgA&i=AwA&r=tryapl&l=apl-dyalog&m=train&n=f)
Sometimes the most straightforward method wins. Space is 1, wall is 0.
### How it works
```
⊢↑1∘-↑-∘2⍴≡    Monadic train; ⍵←dimension vector
      -∘2⍴≡    Create the core of ones of dimensions of ⍵-2
  1∘-↑         Prepend a layer of zeroes by overtaking ⍵-1 in reverse
⊢↑             Append a layer of zeroes by overtaking ⍵
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 12 bytes
Anonymous tacit prefix function.
```
⊂(∨/=,1∊⊢)¨⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT////1FXk8ajjhX6tjqGjzq6HnUt0jy04lHv5v9pj9omPOrte9TV/Kh3zaPeLYfWGz9qm/iob2pwkDOQDPHwDP6fpmDMpaury5WmYKQDhlCeiQ4QQtmmOmZQlqGlDky5oZECAA "APL (Dyalog Unicode) – Try It Online")
`⊂(`…`)¨⍳` apply the following tacit infix function between the entire argument and each index in an array of those dimensions:
 `1∊⊢` is there a `1` in the index?
 `=,` prepend a Boolean list indicating which coordinate are equal to the corresponding element of the original argument
 `∨/` are any true? (lit. OR reduction)
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~14~~ 11 bytes
```
|/~&/|:'\!:
```
[Try it online!](https://ngn.bitbucket.io/k#eJxLs6rRr1PTr7FSj1G04uJKt6quUE5TqKjlSnfQMQYSRgpgCGSZKAAhkDZVMAOShpYKIGkdQyMuADyAD2M=)
@ngn suggested a 13-byter `{|/~x&|'x:!x}` in [chat](https://chat.stackexchange.com/transcript/message/58794299#58794299), which
* overwrites `x` with the odometer (`x:!x`),
* takes element-wise minimum `&` with its row-wise reverse `|'x`,
* and then does `|/~` as below.
The 11-byter above is the result of [`x f g x` trainifying tip](https://codegolf.stackexchange.com/a/231590/78410). 1 in `1|:'\` can be omitted because odometer's reverse is always different from itself (assuming all dimensions are at least 2).
---
# [K (ngn/k)](https://codeberg.org/ngn/k), 14 bytes
```
{|/~(x-1)!'!x}
```
[Try it online!](https://ngn.bitbucket.io/k#eJxLs6qu0a/TqNA11FRUV6yo5eJKt6quUE5TADLTHXSMgYSRAhgCWSYKQAikTRXMgKShpQJIWsfQiAsAhigQeg==)
Same bytecount as [Traws's](https://codegolf.stackexchange.com/a/233060/78410) but different approach. Returns a flattened list of ones on the wall and zeros inside. The helper function `g` reshapes the flattened list into the desired shape.
### How it works
```
{|/~(x-1)!'!x}    monadic function; x: a list
           !x     odometer: column-wise list of coordinates in x-shaped array
    (x-1)!'       use modulo x-1 to convert occurrence of x-1 in each row to zeros
   ~              boolean NOT
 |/               reduce by boolean OR over each column
```
[Answer]
# JavaScript (ES6), 65 bytes
Expects the input list in reverse order.
Very similar to the 66-byte version, but returns a flattened string.
```
f=([n,...a],b='0')=>n?b.replace(/./g,v=>f(a,1+v.repeat(n-2)+1)):b
```
[Try it online!](https://tio.run/##PY49D4IwGIR3fkU32vBS5EMTNcXJxUEHR8LwUgtiSEsKIfHXVwjEyw3P3S33wQkHadt@DLV5KedqQQsNnHMsoRL@zmci15eKW9V3KBWNeNTAJPKaIsTBtPQKR6rDhAUxY6fKnQuPkCIFkpWwUAJk85qzefmPeyCHleIjkHTDpPRKj9fGXlG@KRKRE2n0YDrFO9PQ2/Nx58NoW9209ZfOV@Ybk7KDomyR@wE "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), 66 bytes
Expects the input list in reverse order.
```
f=([n,...a],b=[0])=>n?b.map(v=>f(a,[1,...Array(n-2).fill(v),1])):b
```
[Try it online!](https://tio.run/##LU49C8IwFNz7KzK@wOvD1A9QScXBxUEHx5AhrUmt1KSkpdBfXy31OLg7joN7m8F0ZazbPvXhaafJSVAeichoLKRaaS5zfyroY1oYZO7AoBJzf47RjODTjJOrmwYGjkJzfiimo0oYU2uNs2TI/lzyBtnMJWyR7RYn9sj@C5HpRCfkQryY8gWGyZyVwXehsdSECq6P@426Pta@qt0Iv0cU7WBjZ4HPmL4 "JavaScript (Node.js) – Try It Online")
### Commented
```
f = (                   // f is a recursive function taking:
  [ n,                  //   n = next value from the input list
       ...a ],          //   a[] = all remaining values
  b = [ 0 ]             //   b[] = output, initialized to [ 0 ]
) =>                    //
n ?                     // if n is defined:
  b.map(v =>            //   for each value v in b[]:
    f(                  //     do a recursive call:
      a,                //       pass the remaining values
      [                 //       build an array consisting of:
        1,              //         a leading '1'
        ...Array(n - 2) //         followed by n - 2 values
        .fill(v),       //         set to v
        1               //         followed by a trailing '1'
      ]                 //       end of array
    )                   //     end of recursive call
  )                     //   end of map()
:                       // else:
  b                     //   we're done: return b[]
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/) with Image Package, 25 bytes
```
@(d)padarray(e(d-2),+~~d)
```
Anonymous function that inputs a vector with the coordinates and outputs an *n*-dimensional array. Wall and space are respectively `0` and `e` (equal to `2.71828...`)
Note that, when displaying, the first dimension corresponds to the vertical direction.
[**Try it online!**](https://tio.run/##y08uSSxL/Z9mq6en999BI0WzIDElsagosVIjVSNF10hTR7uuLkXzf5pGtHGspo5CSmZxgYa6LhJQ1@QCShopgCE@JSYKQIhPgamCGT5pQ0sFvE4wxGn7fwA "Octave – Try It Online")
### Explanation
```
@(d)padarray(e(d-2),+~~d)
@(d)                      % Define anonymous function
             e(d-2)       % N-dim array containing e, with side lengths given by d-2
                    +~~d  % Negate d twice, cast to double: gives vector of N ones (**)
    padarray(      ,    ) % Add a frame of zeros to (*) with thickness (**) in each dim
```
[Answer]
# [Haskell](https://www.haskell.org/), 57 bytes
```
s[]="0"
s(a:b)|k<-[1..product b]>>"1"=k++([3..a]>>s b)++k
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/vzg61lbJQImrWCPRKkmzJttGN9pQT6@gKD@lNLlEISnWzk7JUMk2W1tbI9pYTy8RyC9WSNLU1s7@n5uYmWdbUJSZV6JSHG2iA4Sx/wE "Haskell – Try It Online")
Builds a flat list since Haskell is strongly typed. Also takes the coordinates in reverse.
[Answer]
# [Python 3.6](https://docs.python.org/3.6/), 63 bytes
```
f=lambda d,w=0:d and[f(d[1:],x)for x in[1,*[w]*(d[0]-2),1]]or w
```
[Try it online!](https://tio.run/##DckxCoAwDADAr2RsSwSr6CD4kpChEoKCVhGh@vrYW@/6nvXMvZnOezoWSSBY5nYSSFlInVCcGF@v5w0vbJkiBiocarTcdB4jc61i173lx6mjAUf23n4 "Python 3 – Try It Online")
Got the and/or mechanism from aeh5040's post. Originally I was just using a ternary operator.
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 65 bytes
```
f=lambda d,o=0:d and[f(t:=d[1:],1),*[f(t,o)]*(d[0]-2),f(t,1)]or o
```
[Try it online!](https://tio.run/##HUzbCgIhEH3vK3zcWSZY3YoS/JJhHgyRFkpFfLCvtzEOnCuc8m2vnPZ7qWNE9/afZ/AqYHabDcqnQHFp1gXSllEDrjNjBl6XQBufDeAsNHCuKo8o3NWRFNHOSAb/EHdBgegVb8L6gXPWhtmeVKlHakuXow4wfg "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 14 bytes
```
{.-@<:{.-&2$1:
```
[Try it online!](https://tio.run/##rVJdS8MwFH3PrziMYRykoUm3gWGVouCTKPha9jBryjpwFZfpwB9f02Y1rKzFh3FI7tfJuTchm2rEaY5YgYIhhLIr4Lh/eXyofniQLJTdr@RYqGpCnu44nvfmY2@Ql5/vK2P0G74Ls8ZredC7Ooms3H4VeptpYvTOxBypgs7WZUKDIKBthOvFSE6SvCEhckY6uGDq4IIZ5s4RkuhDYSglabREfItUsJCJJUkla@CSLYQtMWdQO53MMfcP3h/zopqwc0@ZhZ/aFpnnDbhe01fC5i267uX4w/PUt5mxeXuXY@G0W6djf@jP1rLihkVndPtxqtmPbrcBxWYO6T/dObHqFw "J – Try It Online")
*This is a translation of [Bubbler's nice answer](https://codegolf.stackexchange.com/a/233036/15469) into J.*
I tried a few other approaches, including stumbling on the same one Adam used, but in J Bubbler's approach was easily the shortest.
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 14 bytes
```
|/:/{~x#!x-1}'
```
[Try it online!](https://ngn.bitbucket.io/k#eJxLs6rRt9KvrqtQVqzQNaxV5+JKc9AxBhJGCmAIZJkoACGQNlUwA5KGlgogaR1DIy4Avr4NUg==)
```
    {       }'            for each dimension apply the function in lambda
      x#!x-1              overtake n from the range of n-1,        e.g. 0 1 2 3 4 0 for n=6
     ~                    "not" the array to get ones at the edges e.g. 1 0 0 0 0 1
|/:/                      max table along all dimensions
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
Œp’ỊƇƇo⁸ŒṬ
```
[Try it online!](https://tio.run/##y0rNyan8///opIJHDTMf7u461n6sPf9R446jkx7uXPNf53D7w537HjWtyXrUMEdB107hUcNcrsPtQIHI//@jo41jdaKNdMAQyDLRAUIgbapjBiQNLXVA0oZGsbEA "Jelly – Try It Online")
A monadic link taking a list of integers and returning a list of the appropriate depth of 0s and 1s. Works by generating a list of all of the coordinates, keeping only those that are the walls and using the multidimensional untruthy link to generate the final list.
[Answer]
# [Coconut](http://coconut-lang.org/), 68 bytes
Uses the recursive method described in the challenge. Takes input in reversed order.
```
g=(x,k)->x*0==0and[1,*[x]*(k-2),1]or[*map(g$(?,k),x)]
reduce$(g,?,0)
```
[Try it online!](https://tio.run/##LU@7DoQgEOzvKygswKxEvEdyBfohhMIoGmMQAnixuH/nwDNTzGx2diY7mMFse4hx5viAlVTtUdac1/02CgalOGSJ16ohwKRxotS9xXOBu@SEg8jbxJ0a90EVeIYOahInZzSy1i1bQIu2xoVrugXlg0ccCXGXgEQDJ7J8QEIWT3hlYm84LayR8jr7tihVF/ifRelEqVMf5bwaSV6mJ/yuVfwB "Coconut – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 32 bytes
```
map(elem 0).mapM(\i->0:[2-i..0])
```
[Try it online!](https://tio.run/##HYxNCsMgFIT3PcVbKqgY@wMNpDfICYwLCdpKNUj1/HlV@RbzLWbmY8vXxYh@2TDZTFx0CSQVzVeyBf6Ss1Y8CCENxepKLbCA1lfDQCs26HpjjS539ugxPdmoTMqYS7LhaKt@CST/wlFBgKcw7vDcfbTvgnzP@Q8 "Haskell – Try It Online")
Outputs a flat list of Booleans
[Answer]
# [Julia 0.7](http://julialang.org/), ~~39~~ 37 bytes
```
x->(a=ones(x);a[(:).(2,x.-1)...]=0;a)
```
[Try it online!](https://tio.run/##rVLLCoMwELznKxZ6SWAbjPZBK/EregseAipYRKWmYL/eRvuwikoPModsZiezu2Gv9yzVxyaRTb0NqJZFHle0Zr5W9Mw4dbHmW8E456F0fM0aE1emkoooLwTcgAxACXRQhES52OHLfyBsFl8HtMGIeXN/6L7KVT3Btr5Di0HjNo@9dCHsbfuM0/3IOFxPv9xPO9AeDz/jvHPDgqOi89f@bessTuhNW89jaDuPccEFx64Vd7CDU34kJElxAwMSus0lAFFalZl@0IRe7mUWU8MYs3R5S3OT5ZSROI@aJw "Julia 0.7 – Try It Online")
Takes input as a tuple of dimensions, outputs a multidimensional array with `1`s and `0`s formatted as floats.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 28 bytes
```
≔0ζ≔1ηＦ⮌θ«≔Ｅι⎇﹪κ⊖ιζηζ≔Ｅιηη»ζ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/9@xuDgzPU9DyUBJR6FK05oLxjcE8jOA/LT8IgWNoNSy1KLiVI1CTU2Fai5OqBrfxAKNTB2FkNSivMSiSg3f/JTSnHyNbB0Fl9TkotTc1LyS1BSNTE1NoMEgszQhFqDpztCE2FPLFVCUmVeiAVTy/390tLGOiY5pbOx/3bIcAA "Charcoal – Try It Online") Link is to verbose version of code. Outputs vertically with ever larger number of newlines as delimiters between different dimensions. Explanation:
```
≔0ζ≔1η
```
Start with `0` as the hollow room and `1` as a solid room.
```
Ｆ⮌θ«
```
Loop through the dimensions in reverse order so that the innermost dimension is processed first.
```
≔Ｅι⎇﹪κ⊖ιζηζ
```
For the next level of hollow room, take the number of rooms and make the first and last solid.
```
≔Ｅιηη
```
The next level of solid rooms is just an array of the appropriate number of solid rooms of the previous level.
```
»ζ
```
Output the final hollow room.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 10 bytes
```
∨∘⌽⍨∘,0∊¨⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG9qZv6jtgkG/x91rHjUMeNRz95HvSCGjsGjjq5DKx71bv6fBpR/1Nv3qKv5Ue@aR71bDq03ftQ2EagzOMgZSIZ4eAZD1XQ@6loEVJDGlaZgzKWrqwukjXTAEMoz0QFCKNtUxwzKMrTUgSk3NFIAAA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ÎvTyo<y<o>‚b‡
```
Straight-forward approach. Can definitely be golfed a bit with a smarter approach.  
Output is a flattened string.
[Try it online](https://tio.run/##yy9OTMpM/f//cF9ZSGW@TaVNvt2jhllJjxoW/q@1DT683jOorPLwllqd/9HGOiaxAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX6mj5F9aAuP8NyguC6nMt6m0ybd71DAr6VHDwv@1tsGH11cGlVUe3lKrc2ib/f/oaNNYnWgzHRMgaaJjAqaNISQQG@lAIZBtqmMGljO0BFKGRrGxAA).
**Explanation:**
```
Î           # Push 0 and the input-list
 v          # Loop over the integers `y` of this list:
  T         #  Push 10
   yo<      #  Push 2^y-1 (oeis sequence A000225)
   y<o>     #  Push 2^(y-1)+1 (oeis sequence A000051)
       ‚    #  Pair them together
        b   #  Convert both to a binary string
         ‡  #  Transliterate the [1,0] to ["111...111","100...001"] respectively
            # (after which the result is output implicitly)
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 26 bytes
```
Array[!1{##}a&,a=#]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@9@xqCixMlrR8P2EbdXKyrVAKlFNJ9FWOVbtf0BRZl5JtLKCrp1CWrRybKyCmoK@g0J1tXGtjkK1kQ4UgjgmOkAIYpjqmIEoYx1LEGVoVFv7HwA "Wolfram Language (Mathematica) – Try It Online")
The private-use character is `\[VectorLess]`.
]