239. Sum a Nested List
A nested list is written with brackets and integers, for example:
[1,[2,3],[[4],5]]
Print the total of every integer in it, at any depth. For the example above that is 15.
This is the case recursion handles and a loop genuinely struggles with, because the shape of the data is not known in advance. A list may contain integers, or lists, which may contain lists, to any depth.
Read one character at a time. A digit begins a number, a [ begins a nested
list, and a ] ends the one you are in.
Constraints - `1 ≤ length of the line ≤ 100000` - Nesting depth is at most 100. - Each integer is between 0 and 1000000.
Input
A single line containing a nested list. It uses only digits, commas, and square brackets, with no spaces. Integers are non-negative.
Output
Print one integer, the sum of every integer at any depth.