Skip to main content
Commonmark migration
Source Link

##Bonus challenge: using two IPs? 40 bytes

Bonus challenge: using two IPs? 40 bytes

###Update: Stack transfer

Update: Stack transfer

##Bonus challenge: using two IPs? 40 bytes

###Update: Stack transfer

Bonus challenge: using two IPs? 40 bytes

Update: Stack transfer

TIO links
Source Link

#Runic, 34 bytes

Runic Enchantments, 33 bytes

Try it online!

###Bonus##Bonus challenge: using two IPs? 40 bytes

Try it online!

As there's no way to clone the input to a second instruction pointer (I have thought about stack cloning, so this may be possible in the future, but the spec for it would be difficult to implement), we have to read it from the input stream twice.

But this is an admittedly dubious answer due to how it has to take input, but 43 bytes shorter than the single IP answer, which is interesting.

Try it online!

###Update: Stack transfer

Getting the two pointers to enter the T command in the right execution order is a huge pain. The remaining two spaces in this program can't be removed, as it messes with the timing, but it avoids having to supply the input value twice. Prints 2 spaces between each entry in the sequence (35 bytes).

>1$0y TR1-:0)?;1\
 >1i:1/U}$:+{$ '/

Try it online!

#Runic, 34 bytes

###Bonus challenge: using two IPs? 40 bytes

As there's no way to clone the input to a second instruction pointer (I have thought about stack cloning, so this may be possible in the future, but the spec for it would be difficult to implement), we have to read it from the input stream twice.

But this is an admittedly dubious answer due to how it has to take input, but 4 bytes shorter than the single IP answer, which is interesting.

Runic Enchantments, 33 bytes

Try it online!

##Bonus challenge: using two IPs? 40 bytes

Try it online!

As there's no way to clone the input to a second instruction pointer (I have thought about stack cloning, so this may be possible in the future, but the spec for it would be difficult to implement), we have to read it from the input stream twice.

But this is an admittedly dubious answer due to how it has to take input, but 3 bytes shorter than the single IP answer, which is interesting.

Try it online!

###Update: Stack transfer

Getting the two pointers to enter the T command in the right execution order is a huge pain. The remaining two spaces in this program can't be removed, as it messes with the timing, but it avoids having to supply the input value twice. Prints 2 spaces between each entry in the sequence (35 bytes).

>1$0y TR1-:0)?;1\
 >1i:1/U}$:+{$ '/

Try it online!

Source Link

#Runic, 34 bytes

/01iR1-:0)?;{1+:
\$1<\}$q}:+1{$ '

Uncompressing the entry sequence and moving the reflectors to the other side:

>1$01iR1-:0)?;{1+:\
      \}$q}:+1{$ '/

Entry sequence (>1$01i) is fairly straight forward. Push and print 1, push 0, push 1, read input and push it to the top of the stack.

At R we enter the program's main loop (unrolled with directional control characters removed):

1-:0)?;{1+:' ${1+:}q$}

At this point the stack is [0,1,i] where i is the input value.

The loop subtracts 1 from the input value (1-), compares it to greater than 0 (if true, skip terminator, else terminate; :0)?;).

Then a series of stack manipulations ({1+:{1+:}) and increments to result in [2,(i-1),1,1,2] as well as printing a space (' $). q then concats the top two items on the stack, which is then printed (giving 12 in the output stream).

Finally the stack is rotated once more, leaving [1,2,(i-1)] as the input to the next loop iteration.

###Bonus challenge: using two IPs? 40 bytes

>1$0iR1-:0)?;1{+:' \
> F1iU }$~?=am$?=9m/

As there's no way to clone the input to a second instruction pointer (I have thought about stack cloning, so this may be possible in the future, but the spec for it would be difficult to implement), we have to read it from the input stream twice.

Flow results in the second pointer being a step behind the first (avoiding merging) and the Fizzle lets us distinguish the two IPs, letting one print a space and the other discards it. I can't figure out a shorter way of performing this check.

However if it allowable to print two spaces as a separator it can be reduced to this (30 bytes):

>1$0iR1-:0)?;1\
> F1iU}$:+{$ '/

input: 4 4
output: 1  12  23  34

But this is an admittedly dubious answer due to how it has to take input, but 4 bytes shorter than the single IP answer, which is interesting.