Partially inspired by this question.
The execution of Goggle kids Code starts with an empty binary tape with 100 items, with the pointer starting at the index 0:
At the end of the execution, you can assume that the tape is implicitly outputted.
Goggle kids Code is a simple language involving a stack-like tape.
/: Move the pointer right.
\: Move the pointer left.
>: Take two items from the tape, the left item and the current item. Zero the current item, move left, and set the item as 1 if
leftis larger than
current, else 0.
=: Similar to
>, but performs an equality comparison instead.
The only looping structure in Goggle kids Code is the repeat loop, which takes a strictly positive number on the right introduced by a
x symbol. (So things like
(...)x0 is impossible here.) The syntax for this is:
The parentheses can only contain single instructions, although you can introduce other instructions with commas.
Sample program + Explanation
((/,>)x4,/)x13 ( )x13 Do this 13 times: ( )x4 Do this 4 times: / Move right , After that, > Greater than , After that, / Move pointer right.
Another example that does something useful (fills 13 items from the tape with 1's):
( )x13 Do this 13 times: / Move right , After that, = Equality
- You can assume the tape pointer never wraps around.
- The test cases won't abuse out-of-bounds tape-moving.
- To simplify the solution, you are allowed to output part of the tape, as long as that part is modified.
- You are allowed to have a different instruction mapping, but if you do that, please make sure to clarify which mapping you used.
- You could ignore checking the commas in the source code, they'll always be there.
- Instructions are always separated by the comma.
0 digits are omitted here, for compactness of example outputs.
((/,>)x4,/)x13 -> 0000000000000 (doesn't modify the tape) (/,=,/)x13 -> 1111111111111 (/,=,/,/)x13 -> 1010101010101010101010101 (/,=)x13,/,= -> 00000000000000000 (/,/,=,\)x3 -> 0100 ```