The challenge is simple: write a program or function that, when given a finite non-negative integer, outputs a nested array.
The rules
- Your code must produce a unique valid nested array for every integer 0 ≤ n < 231.
- Every possible nested array with up to 16 open brackets must be outputted within this range. (This does not mean that your code can never output a nested array with more than 16 open brackets.)
- Your code may output a string representation of the nested array instead of an actual array (with or without commas).
One possible mapping:
0 -> []
1 -> [[]]
2 -> [[[]]]
3 -> [[], []]
4 -> [[[[]]]]
5 -> [[[], []]]
6 -> [[[]], []]
7 -> [[], [[]]]
8 -> [[], [], []]
9 -> [[[[[]]]]]
etc.
Scoring
This is code-golf, so the shortest code in bytes wins.