21
1
Task
Given a wrapper element and a non-jagged 3D array, wrap the array top, bottom, and all-around. You must handle both character and numeric data, but the wrapper and the present will have the same data type.
Character example
For character data, you may chose to handle either 3D arrays of single characters or 2D arrays of strings:
Given the 2 layer, 2 row, 4 column character array
[[["Y","o","u","r"],
["g","i","f","t"]],
[["g","o","e","s"],
["h","e","r","e"]]]
and the character "."
, answer the 4 layer, 4 row, 6 column character array
[[[".",".",".",".",".","."],
[".",".",".",".",".","."],
[".",".",".",".",".","."],
[".",".",".",".",".","."]],
[[".",".",".",".",".","."],
[".","Y","o","u","r","."],
[".","g","i","f","t","."],
[".",".",".",".",".","."]],
[[".",".",".",".",".","."],
[".","g","o","e","s","."],
[".","h","e","r","e","."],
[".",".",".",".",".","."]],
[[".",".",".",".",".","."],
[".",".",".",".",".","."],
[".",".",".",".",".","."],
[".",".",".",".",".","."]]]
or given the 2 row, 2 column array of 4-character strings
[["Your",
"gift"],
["goes",
"here"]]
and the character "."
, answer the 4 row, 4 column array of 6-character strings
[["......",
"......",
"......",
"......"],
["......",
".Your.",
".gift.",
"......"],
["......",
".goes.",
".here.",
"......"],
["......",
"......",
"......",
"......"]]
Numeric example
Given the 2 layer, 2 row, 2 column numeric array
[[[1,2],
[3,4]],
[[5,6],
[7,8]]]`
and the number 0
, answer the 4 layer, 4 row, 4 column numeric array
[[[0,0,0,0],
[0,0,0,0],
[0,0,0,0],
[0,0,0,0]],
[[0,0,0,0],
[0,1,2,0],
[0,3,4,0],
[0,0,0,0]],
[[0,0,0,0],
[0,5,6,0],
[0,7,8,0],
[0,0,0,0]],
[[0,0,0,0],
[0,0,0,0],
[0,0,0,0],
[0,0,0,0]]]
Can we assume the length of each "gift element" to wrap is identical? – XavCo7 – 2016-12-20T14:25:50.883
@XavCo7 Yes you can. – Adám – 2016-12-20T14:28:07.867
Related. – Martin Ender – 2016-12-20T14:51:29.313
What kind of output is acceptable. Need it be a datastructure of a three d array or is textual output acceptable – Rohan Jhunjhunwala – 2016-12-20T17:07:09.050
@RohanJhunjhunwala You may freely choose representation, but input and output formats must be the same. – Adám – 2016-12-20T17:44:41.563
@Adám Congrats on 10k!! – Luis Mendo – 2016-12-20T19:51:53.507
@LuisMendo Thanks. I guess that'll be by seasonal present from SE :-) – Adám – 2016-12-20T20:29:40.610
In the example of 3D char arrays, the wrapped gift says 'Your gift/goea here', do we need to edit the string? – boboquack – 2016-12-21T00:25:29.517