0 with 1/3 probability,
1 with 2/3 probability. Try it online!
I think this is the first time I've had to pad the source code with no-ops to make the cube the correct size...
Cubix is a 2D stack-based esolang wrapped around a cube. The source code won't fit onto a size-1 cube, and so it gets wrapped around a size-2 cube, with the following cube net:
D 1 . . . . . .
. . . . . . . .
The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing east. The first instruction it hits is
D, which points the IP in a random direction. This isn't the best possible source of randomness for this challenge, but it's the only one Cubix has.
If the IP is pointed north, it wraps onto the
w on the top face, which moves the IP one position to the right (south at this point).
O outputs the top item on the stack as a number (
0 if the stack is empty), and
@ ends the program.
If the IP is pointed south, it wraps around various faces before hitting the
> on the top face. It's going west at this point, and
> points the cursor east, sending it back to the
D, which starts the whole process over.
If the IP is pointed east or west, it simply wraps around the third row of the above diagram, hitting the
1 at some point in the middle. When it gets back to the
D, the process is started again as before, but when the IP eventually gets sent north,
1 instead of
So each time
D is hit, there's a 2/4 chance that the output will be
1, and a 1/4 chance that it will be
0. The other 1/4 is simply the chance of the process starting over, and so if we sum the infinitely shrinking chances of each output, we get 2/3 for
1 and 1/3 for