Skip to main content
Saved 2B
Source Link
Luke
  • 4.8k
  • 16
  • 23

Cubix, 1212 10 bytes

*,)2I://O@

Initial version

....I:)*2,O@

Try it online!Try it online!

Explanation

Expanded onto a cube, the code looks like this:

    .* .,
    .) .2
I : ) * 2/ ,/ O @ . .
. . . . . . . .
    . .
    . .

In this caseThe instruction pointer (IP) starts at the I, moving east. It continues moving east until it comes across the / mirror, which reflects it north. When the IP reaches the top of the code is linear, so it's easyit wraps around to explainthe last . on the third line, moving south. Then it wraps to the penultimate . on the last line, moving north. Then it reaches the / mirror again, which reflects it east, only for the next / to reflect it north again. This istime, the orderIP wraps to the commandspenultimate . on the third line, and then the last . on the last line.

The instructions are executed in the following order.

I:)*2,O@ # Explanation
I        # Take input as an integer and push it to the stack
 :       # Duplicate the input
  )      # Increment one of the inputs
   *     # Multiply the input by input+1
    2    # Push 2 to the stack
     ,   # Integer devide the multiplication result by 2
      O  # Output the result
       @ # End program

Cubix, 12 bytes

....I:)*2,O@

Try it online!

Explanation

Expanded onto a cube, the code looks like this:

    . .
    . .
I : ) * 2 , O @
. . . . . . . .
    . .
    . .

In this case, the code is linear, so it's easy to explain. This is the order the commands are executed.

I:)*2,O@ # Explanation
I        # Take input as an integer and push it to the stack
 :       # Duplicate the input
  )      # Increment one of the inputs
   *     # Multiply the input by input+1
    2    # Push 2 to the stack
     ,   # Integer devide the multiplication result by 2
      O  # Output the result
       @ # End program

Cubix, 12 10 bytes

*,)2I://O@

Initial version

....I:)*2,O@

Try it online!

Explanation

Expanded onto a cube, the code looks like this:

    * ,
    ) 2
I : / / O @ . .
. . . . . . . .
    . .
    . .

The instruction pointer (IP) starts at the I, moving east. It continues moving east until it comes across the / mirror, which reflects it north. When the IP reaches the top of the code, it wraps around to the last . on the third line, moving south. Then it wraps to the penultimate . on the last line, moving north. Then it reaches the / mirror again, which reflects it east, only for the next / to reflect it north again. This time, the IP wraps to the penultimate . on the third line, and then the last . on the last line.

The instructions are executed in the following order.

I:)*2,O@ # Explanation
I        # Take input as an integer and push it to the stack
 :       # Duplicate the input
  )      # Increment one of the inputs
   *     # Multiply the input by input+1
    2    # Push 2 to the stack
     ,   # Integer devide the multiplication result by 2
      O  # Output the result
       @ # End program
Source Link
Luke
  • 4.8k
  • 16
  • 23

Cubix, 12 bytes

....I:)*2,O@

Try it online!

Explanation

Expanded onto a cube, the code looks like this:

    . .
    . .
I : ) * 2 , O @
. . . . . . . .
    . .
    . .

In this case, the code is linear, so it's easy to explain. This is the order the commands are executed.

I:)*2,O@ # Explanation
I        # Take input as an integer and push it to the stack
 :       # Duplicate the input
  )      # Increment one of the inputs
   *     # Multiply the input by input+1
    2    # Push 2 to the stack
     ,   # Integer devide the multiplication result by 2
      O  # Output the result
       @ # End program