#K55827. Create a Multidimensional Array with Consecutive Integers

    ID: 30062 Type: Default 1000ms 256MiB

Create a Multidimensional Array with Consecutive Integers

Create a Multidimensional Array with Consecutive Integers

You are given four integers a, b, c, and d. Your task is to construct a 4-dimensional array (although the function name is create_3d_array, it actually returns a 4D nested array) with dimensions a × b × c × d, where the array is filled with consecutive integers starting from 0. The resulting array should be represented using nested list notation as in Python.

Note: Although the terminology might suggest a 3D array, the four parameters represent the number of matrices, rows, columns, and the depth of each element, respectively.

For example, if the input is 2 3 4 2, the output should be a deeply nested list:

[[[[0, 1], [2, 3], [4, 5], [6, 7]], [[[8, 9], [10, 11], [12, 13], [14, 15]], [[16, 17], [18, 19], [20, 21], [22, 23]]], [[[[24, 25], [26, 27], [28, 29], [30, 31]], [[32, 33], [34, 35], [36, 37], [38, 39]], [[40, 41], [42, 43], [44, 45], [46, 47]]]]

inputFormat

The input is given as a single line of four space-separated integers: a, b, c, and d.

For example:

2 3 4 2

outputFormat

The output should be the constructed multidimensional array printed in nested list format.

For example:

[[[[0, 1], [2, 3], [4, 5], [6, 7]], [[8, 9], [10, 11], [12, 13], [14, 15]], [[16, 17], [18, 19], [20, 21], [22, 23]]], [[[24, 25], [26, 27], [28, 29], [30, 31]], [[32, 33], [34, 35], [36, 37], [38, 39]], [[40, 41], [42, 43], [44, 45], [46, 47]]]]
## sample
2 3 4 2
[[[[0, 1], [2, 3], [4, 5], [6, 7]], [[8, 9], [10, 11], [12, 13], [14, 15]], [[16, 17], [18, 19], [20, 21], [22, 23]]], [[[24, 25], [26, 27], [28, 29], [30, 31]], [[32, 33], [34, 35], [36, 37], [38, 39]], [[40, 41], [42, 43], [44, 45], [46, 47]]]]