Skip to main content
:P
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

Cubix, 7 bytes

w>O@D1.

Outputs 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easyeast. 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, O outputs 1 instead of 0.

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 0.

Cubix, 7 bytes

w>O@D1.

Outputs 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easy. 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, O outputs 1 instead of 0.

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 0.

Cubix, 7 bytes

w>O@D1.

Outputs 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...

Explanation

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:

    w >
    O @
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, O outputs 1 instead of 0.

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 0.

added 4 characters in body
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

Cubix, 7 bytes

w>O@D1.

Outputs 00 with 1/3 probability, 11 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easy. 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, O outputs 1 instead of 0.

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 0.

Cubix, 7 bytes

w>O@D1.

Outputs 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easy. 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, O outputs 1 instead of 0.

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 0.

Cubix, 7 bytes

w>O@D1.

Outputs 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easy. 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, O outputs 1 instead of 0.

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 0.

it's 1:2
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

Cubix, 7 bytes

w>O@D1.

Outputs 0/1 with... actually 1/3 probability, I don't know what the1 with 2/3 probability is. 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easy. 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, O outputs 1 instead of 0.

So the chance ofeach time 0D being outputted instead ofis 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 IP being directed north before it's directed either east or west. Now to figure out whatprocess starting over, and so if we sum the chanceinfinitely shrinking chances of that is..each output, we get 2/3 for 1 and 1/3 for 0.

Cubix, 7 bytes

w>O@D1.

Outputs 0/1 with... actually, I don't know what the probability is. 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easy. 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, O outputs 1 instead of 0.

So the chance of 0 being outputted instead of 1 is the chance of the IP being directed north before it's directed either east or west. Now to figure out what the chance of that is...

Cubix, 7 bytes

w>O@D1.

Outputs 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...

Explanation

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:

    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing easy. 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, O outputs 1 instead of 0.

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 0.

added 1544 characters in body
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading