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 1s.
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, 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.
111110011111the result of[4,3]rather than[3,4]? \$\endgroup\$