Skip to main content
added 67 characters in body
Source Link
TwilightSparkle
  • 3.9k
  • 1
  • 17
  • 33

1+, 10 bytes

."#:[#":1#

Yay for comment abuse in a normal challenge (instead of a source-layout or polyglot one)! In 1+, the [ character that begins a comment is actually an instruction so it can be skipped with the goto command #.

For input 0:

.          Take input
 "#        Jump to the 0th hash tag
   :      Output 0
    [      Comment the rest of the program out

For input 1:

.          Take input
 "#        Jump to the 1th hash tag
     #     The 1th hash tag
      ":   Duplicate and output
        1# Jump to the 1th hash tag

I can replace the 1 with " as well so that we get a 1+ program without a 1 instruction... Wow!

Naive solution, 14 bytes

.1##":"1+1<1+#

A simple do-while loop.

1+, 10 bytes

."#:[#":1#

Yay for comment abuse! In 1+, the [ character that begins a comment is actually an instruction so it can be skipped with the goto command #.

For input 0:

.          Take input
 "#        Jump to the 0th hash tag
   :      Output 0
    [      Comment the rest of the program out

For input 1:

.          Take input
 "#        Jump to the 1th hash tag
     #     The 1th hash tag
      ":   Duplicate and output
        1# Jump to the 1th hash tag

I can replace the 1 with " as well so that we get a 1+ program without a 1 instruction... Wow!

Naive solution, 14 bytes

.1##":"1+1<1+#

A simple do-while loop.

1+, 10 bytes

."#:[#":1#

Yay for comment abuse in a normal challenge (instead of a source-layout or polyglot one)! In 1+, the [ character that begins a comment is actually an instruction so it can be skipped with the goto command #.

For input 0:

.          Take input
 "#        Jump to the 0th hash tag
   :      Output 0
    [      Comment the rest of the program out

For input 1:

.          Take input
 "#        Jump to the 1th hash tag
     #     The 1th hash tag
      ":   Duplicate and output
        1# Jump to the 1th hash tag

I can replace the 1 with " as well so that we get a 1+ program without a 1 instruction... Wow!

Naive solution, 14 bytes

.1##":"1+1<1+#

A simple do-while loop.

Source Link
TwilightSparkle
  • 3.9k
  • 1
  • 17
  • 33

1+, 10 bytes

."#:[#":1#

Yay for comment abuse! In 1+, the [ character that begins a comment is actually an instruction so it can be skipped with the goto command #.

For input 0:

.          Take input
 "#        Jump to the 0th hash tag
   :      Output 0
    [      Comment the rest of the program out

For input 1:

.          Take input
 "#        Jump to the 1th hash tag
     #     The 1th hash tag
      ":   Duplicate and output
        1# Jump to the 1th hash tag

I can replace the 1 with " as well so that we get a 1+ program without a 1 instruction... Wow!

Naive solution, 14 bytes

.1##":"1+1<1+#

A simple do-while loop.