23
1
Here is some example input, so I can explain what the problem is:
((1 2)(3 (4 5) moo)) (i (lik(cherries)e (woohoo)))
Think of this line of text as a topographic map of some mountains. Each set of parentheses illustrates one unit of altitude.
If we "view" this from the side, so that we see the mountains vertically, we will see:
4 5 cherries woohoo
1 2 3 moo lik e
i
Given one of these topographic maps, output the map, but on a vertical scale, like the output above. Seperate the different items in the map with the number of characters to the next item. For example, there are 4 spaces in the output between moo
and i
. Likewise, there are 4 characters in the input between moo
and i
.
The code which does this in the least amount of characters wins.
Is it safe to assume that heights will always be positive? For example, the input
((1 2))))))))))3
should be invalid if negative heights are forbidden. – Cristian Lupascu – 2012-07-12T13:53:30.273@w0lf: yep, the parentheses will always match up. – beary605 – 2012-07-12T13:56:14.613