15
3
You will be given a nested array. Your program has to visualize the array.
But.. How?
For example, let's assume we have a nested array, like [["1","2"],[["1","2"],"3"],"4",[[[["5"]]]],"6"]
.
This nested array can be visualised as:
->1
->2
-->1
-->2
->3
>4
---->5
>6
Examples
Input 1:
["Atom",["Proton",["Up Quark", "Up Quark", "Down Quark"], "Neutron", ["Up Quark", "Down Quark", "Down Quark"], "Electron"]]
Output 1:
>Atom
->Proton
-->Up Quark
-->Up Quark
-->Down Quark
->Neutron
-->Up Quark
-->Down Quark
-->Down Quark
->Electron
Input 2:
[["1","2"],["3","4"]]
Output 2:
->1
->2
->3
->4
Rules
- You may use string (or other types which work like a nested array) as input.
- The maximum level of "layers" is 2^32-1.
Does it have to have this exact visualisation? – penalosa – 2017-03-21T09:14:22.723
@mnbvc Yes, unless I force to do it people start to twist the I/O a lot. Believe me, I tried it. – Matthew Roh – 2017-03-21T09:21:47.920
I feel like retina will win this. – Magic Octopus Urn – 2017-03-21T13:23:17.683
1Are there any restrictions on what characters can appear in the strings? – Martin Ender – 2017-03-21T14:43:43.650
Additional related questions 1, 2
– AdmBorkBork – 2017-03-21T15:38:00.340Do we have to handle inconsistent separators? If yes, will whitespace characters occur only after the comma? Will there be only 0 or 1 whitespace or can be even more? – manatwork – 2017-03-22T08:38:35.437