Given a positive integer n
.
Generate a JSON array (can be a string, or your language's built-in JSON representation as long as we can get valid JSON, (your code does not need to include outputting the string, you can just use the built-in JSON representation)) containing two empty JSON arrays, then, add a set of 2 empty JSON arrays to each existing set of 2 empty JSON arrays up to n
deep. n
can be 0 or 1 indexed.
Rules
- The shortest code wins the challenge (as this is code-golf).
- All output JSON must be RFC8259 compliant.
Examples
Input: 0
Output: [[], []]
Input: 1
Output: [[[], []], [[], []]]
Input: 2
Output: [[[[], []], [[], []]], [[[], []], [[], []]]]
-1
should give[]
then, no? \$\endgroup\$-1
should be a valid input, just that if we run the transformation rule in reverse from[[],[]]
we get[]
. Also, this community enjoys having input rule lax, and it is common to allow both 0-indexing and 1-indexing. \$\endgroup\$