7 changed link
source | link

Cubix, 23 19 17 bytes

;;u!I1)%/;O=!;;/;

Try it!Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    ; ;
    u !
I 1 ) % / ; O =
! ; ; / ; . . .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • / (47) : turn left
  • ! (33) : skip next instruction if odd
    • 1;;/; ; is (59) : prepares the stack for output
    • O (79) : Output as a number.
    • Then it re-enters the algorithm but I reads a 0 for end of input, so we are guaranteed to enter the even branch
  • u (117) : right-hand u-turn
  • ;;;!I : loop, effectively doing nothing.

Cubix, 23 19 17 bytes

;;u!I1)%/;O=!;;/;

Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    ; ;
    u !
I 1 ) % / ; O =
! ; ; / ; . . .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • / (47) : turn left
  • ! (33) : skip next instruction if odd
    • 1;;/; ; is (59) : prepares the stack for output
    • O (79) : Output as a number.
    • Then it re-enters the algorithm but I reads a 0 for end of input, so we are guaranteed to enter the even branch
  • u (117) : right-hand u-turn
  • ;;;!I : loop, effectively doing nothing.

Cubix, 23 19 17 bytes

;;u!I1)%/;O=!;;/;

Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    ; ;
    u !
I 1 ) % / ; O =
! ; ; / ; . . .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • / (47) : turn left
  • ! (33) : skip next instruction if odd
    • 1;;/; ; is (59) : prepares the stack for output
    • O (79) : Output as a number.
    • Then it re-enters the algorithm but I reads a 0 for end of input, so we are guaranteed to enter the even branch
  • u (117) : right-hand u-turn
  • ;;;!I : loop, effectively doing nothing.
6 added 116 characters in body
source | link

Cubix, 23 1919 17 bytes

u;;uI1;;u!I1)%u===O;;%/;O=!;;/;

Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    u; ;
    ; u !
I 1 ) % u/ =; =O =
O! ; ; / ! ; ;. . .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • u/ (11747) : right-hand u-turnturn left
  • !/ (33) and (47) : turn left if even, go straightskip next instruction if odd
  • odd branch:
    • ;;1;;/; : pops the +/- 1; and theis 2(59) off: prepares the stack for output
    • O (79) : Output as a number.
    • Then it re-enters the algorithm but ;;I pops the top of stack, leaving it emptyreads a (TOS is zero)
    • !/0 is then hit, and TOS is evenfor end of input, so we are guaranteed to enter the even branch.
  • even branchu (117) :
    • ;= : effective no-ops, then
    • u;u; : the infinite loop
    right-hand u-turn
  • ;;;!I : loop, effectively doing nothing.

Cubix, 23 19 bytes

u;;uI1)%u===O;;/!;;

Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    u ;
    ; u
I 1 ) % u = = =
O ; ; / ! ; ; .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • u (117) : right-hand u-turn
  • !/ (33) and (47) : turn left if even, go straight if odd
  • odd branch:
    • ;; : pops the +/- 1 and the 2 off the stack
    • O (79) : Output as a number.
    • ;; pops the top of stack, leaving it empty (TOS is zero)
    • !/ is then hit, and TOS is even, so we enter the even branch.
  • even branch:
    • ;= : effective no-ops, then
    • u;u; : the infinite loop

Cubix, 23 19 17 bytes

;;u!I1)%/;O=!;;/;

Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    ; ;
    u !
I 1 ) % / ; O =
! ; ; / ; . . .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • / (47) : turn left
  • ! (33) : skip next instruction if odd
    • 1;;/; ; is (59) : prepares the stack for output
    • O (79) : Output as a number.
    • Then it re-enters the algorithm but I reads a 0 for end of input, so we are guaranteed to enter the even branch
  • u (117) : right-hand u-turn
  • ;;;!I : loop, effectively doing nothing.
5 added 261 characters in body
source | link

Cubix, 23 19 bytes

u;;uI1)%u;====\=?;O%u===O;;/!;;

Try it!Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    u ;
    ; u
I 1 ) % u ;= = =
=O =; \; =/ ?! ; O; .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • u (117) : right-hand u-turn
  • ?!/ (6333) and (47) : turn rightleft if oddeven, go straight if even
  • even branch:
    • =\) : = and ) are effective no-ops, \ directs the IP to the infinite loop u;u;
    odd
  • odd branch:
    • u;;;; : pops the +/- 1 and the 2 off the stack
    • some instructions that don't do anything besides getting the IP to
    • O (79) : outputOutput as a number.
    • some more instructions;; pops the top of stack, thenleaving it enters the infinite loopempty (TOS is zero)
    • uu!/ is then hit, and TOS is even, so we enter the even branch.
  • even branch:
    • ;= : effective no-ops, then
    • u;u; : the infinite loop

Cubix, 23 19 bytes

u;;uI1)%u;====\=?;O

Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

Cube version:

    u ;
    ; u
I 1 ) % u ; = =
= = \ = ? ; O .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • u (117) : right-hand u-turn
  • ? (63) : turn right if odd, go straight if even
  • even branch:
    • =\) : = and ) are effective no-ops, \ directs the IP to the infinite loop u;u;
  • odd branch:
    • u;; : pops the 1 and the 2 off the stack
    • some instructions that don't do anything besides getting the IP to
    • O (79) : output as a number
    • some more instructions, then it enters the infinite loop uu.

Cubix, 23 19 bytes

u;;uI1)%u===O;;/!;;

Try it!

@, which terminates a Cubix program, is ascii 64, so unfortunately this actually just enters an infinite loop after testing for oddness. No TIO link since it'll time out.

= (ascii 61) is a no-op in Cubix.

This is a slight modification of the prior algorithm (same # of bytes) that actually works for negative integers.

Cube version:

    u ;
    ; u
I 1 ) % u = = =
O ; ; / ! ; ; .
    . .
    . .

Algorithm:

  • I (73) : read in input as number
  • 1 (49) : push 1
  • ) (41) : increment
  • % (37) : take the mod
  • u (117) : right-hand u-turn
  • !/ (33) and (47) : turn left if even, go straight if odd
  • odd branch:
    • ;; : pops the +/- 1 and the 2 off the stack
    • O (79) : Output as a number.
    • ;; pops the top of stack, leaving it empty (TOS is zero)
    • !/ is then hit, and TOS is even, so we enter the even branch.
  • even branch:
    • ;= : effective no-ops, then
    • u;u; : the infinite loop
4 edited body
source | link
3 deleted 202 characters in body
source | link
    Post Undeleted by Giuseppe
2 added 327 characters in body
source | link
    Post Deleted by Giuseppe
1
source | link