Your goal is to write a program that prints the string abc in two languages. However, while the full code will print abc in one language (we'll call it Language 1), the other one (Language 2) must print abc if (and only if) every other character is skipped starting from the second character. If the full code is run in language 2, it must throw an error. If the skipped code is run in language 1, likewise, it must throw an error.

Rules and Clarification

  • Trailing newlines are allowed.
  • Output must be lowercase.
  • "Run" means compiled for compiled languages.
  • We will define "throwing an error" as outputting nothing to STDOUT and something to STDERR.

Test Cases

Language 1: 12345 -> abc
Language 1: 135 -> error
Language 2: 135 -> abc
Language 2: 12345 -> error


The shortest code in bytes wins (the full code, not the skipped code).

Edit: I have clarified the rules based on feedback in the comments. The existing answers should still be valid.

  • \$\begingroup\$ Is trailing whitespace allowed in the output? \$\endgroup\$
    – Arnauld
    Commented Oct 25, 2019 at 15:17
  • 2
    \$\begingroup\$ What precisely counts as an error? Is outputting nothing to STDOUT and something to STDERR sufficient? Consider this potential submission, where the Foo program that "errors" encounters an error that doesn't cause the program to halt, but it has no other output. \$\endgroup\$ Commented Oct 25, 2019 at 17:46
  • 1
    \$\begingroup\$ Are we to interpret "run" as "compiled" for compiled languages? Otherwise the implication would be that both shortened and full programs must compile in both languages, but throw run-time errors upon execution if the wrong length. \$\endgroup\$
    – gastropner
    Commented Oct 30, 2019 at 0:50
  • 1
    \$\begingroup\$ Can we output in uppercase (ABC instead of abc)? \$\endgroup\$
    – Grimmy
    Commented Oct 31, 2019 at 13:45

15 Answers 15


brainfuck, 28 26 bytes

a+b[c-/[/---<]>>- ]<-.+.+.

Try it online!

Got the bf code from here.

Fails in Ink due to Expected target for new thread but saw '.+.+.'.



Try it online!

Ink will just print abc and the rest is a comment.

Fails in brainfuck due to mismatched bracket.


Keg, 21 19 bytes (19 17 characters)

abc#1 / ╘ " a b c

Try it online!

Simply prints abc and the rest is a comment.

Fails in MathGolf due to an undefined operator overload of /. / can not work on an integer (1) and a string( pushed via the space instruction.)



Try it online!

Does a bunch of nonsense, then deletes the whole stack. "abc pushes abc and the stack has an implicit output.

Fails in Keg due to the failure of implicit-outputting a floating-point number in its character form.

  • 1
    \$\begingroup\$ Welcome to Keg! \$\endgroup\$
    – lyxal
    Commented Oct 25, 2019 at 22:32

Japt and Pyth, 20 bytes

Both are shortenings of common scripting languages, nice

Japt: "_a_b_c_"v ë2,1 +[] (TIO, error in Pyth)

Pyth: "abc" 21 [ (TIO, error in Japt)


CJam and Gaia, 15 bytes

(CJam only cares about printable ASCII, so Gaia's codepage can be used to encode both programs)


 'a'b'c'” 'ọ;e<

Works in CJam

Errors in Gaia



Works in Gaia

Errors in CJam


This takes some advantage of the fact that ' defines a character literal in both languages.

Full program:

We push 5 characters: a, b, c, , and . ; deletes the and e< leaves the minimum of c and , which is c. The remaining characters (abc) are joined together and output implicitly.

In Gaia, everything up to is a string literal. We then push the char , and then copy (;) the string literal back to the top and attempt to eval it (e). This throws an error because the last character in that string is ', which is improper syntax (a character literal after it is expected).

Reduced program:

(or, more specifically, byte 0xFB) is not defined, so the program terminates with an error.

In Gaia we get the string literal  abc (with leading space). We then push the character and eval it, which is the command for trim. This leaves plain abc on the stack, which is implicitly output.


naz / 7, 54 bytes


This has to be the most esoteric answer I've submitted so far.

Explanation of the full code (works in naz)

6a6a5a5m1a5a1a5a     # Set the register to a value of 97 ("a")
1o                   # Output once
5s1a5a1o             # Output "b"
5s1a5a1o             # Output "c"
0m3a4a1a2a2a7a4a0a3a # Extra arithmetic to allow for a valid 7 program

Fails in 7: 6 command run with no bar in the frame at /opt/7/7.pl line 605, <> chunk 1.

The reduced code (works in 7)


Try it online!

Fails in naz: error: attempt to chain number literals

I can't give a very accurate explanation of the reduced code due to my relatively poor understanding of 7. I invite anyone who can make sense of it to improve this post.


PHP and Emoji, 21 chars, 30 bytes


⛽_a_b_c_🚘➡➡;echo abc;


⛽abc🚘➡eh b;

PHP, Full - Try it online! Prints: abc

Emoji, Skipped - Try it online! Prints: abc

PHP, Skipped - Try it online! Error: PHP Parse error: syntax error, unexpected 'b' (T_STRING)

Emoji, Full - Try it online! Error: IndexError: pop from empty list


JavaScript (V8) and PHP, 29 bytes


print`abc`;'e_c_h_o_ _a_b_c';


pitac;echo abc;

JavaScript, Full - Try it online! Prints: abc

PHP, Skipped - Try it online! Prints: abc

JavaScript, Skipped - Try it online! Error: SyntaxError: Unexpected identifier

PHP, Full - Try it online! Error: abc: command not found


C++ (gcc) / C (gcc), 87 bytes

Full (C++)


) ; }

Skipped (C)


Full C++, Working

Skipped C++, Error

Full C, Error

Skipped C, Working


Backhand and ><>, 39 bytes


8.cv*c0*~]!]/]:::[@:1[[email protected].+.o.;

Prints abc in Backhand

Errors in ><>



Prints abc in ><>

Errors in Backhand


Backhand doesn't execute the instructions one by one. In the full version, it goes 3, then the v instruction turns it to two steps. In the skipped version, this has the consequence that only the first instruction overlaps with the full version.

When you run the skipped version on Backhand, it divides by zero. Errors in backhand don't stop the program, so I added a stop command, which makes ><> a bit harder. (It's still a command in ><>, just not a good one.)

><>, on the other hand, does not skip instructions. In the full version, a . means jump. Fish is a 2D language, so it pops two arguments. However, only 1 thing was pushed (because of 8). Thus, something smells fishy....

How I get around some of the commands in ><> is simple. When 0 is executed, it pushes 0, then it immediately removes it. Then it skips the next command, which is a mirror. Finally, it duplicates twice, meaning 3 of the same thing is in the stack, which means @, which cycles the top 3 items in the stack, does absolutely nothing.

  • \$\begingroup\$ Hi! Welcome to CGCC! I hope you enjoy your stay! \$\endgroup\$
    – lyxal
    Commented Jan 20, 2020 at 9:27
  • 1
    \$\begingroup\$ An interesting way of doing it, but both ><> and Backhand have the " operator, which should make it a lot easier to push strings. You can do something like this for 29 bytes, though I'm sure that's easily golfable, perhaps by swapping the two languages \$\endgroup\$
    – Jo King
    Commented Jan 21, 2020 at 2:45
  • \$\begingroup\$ I only found out about backhand having it after I made this. \$\endgroup\$
    – PkmnQ
    Commented Jan 21, 2020 at 4:53
  • \$\begingroup\$ Errors in backhand don't stop the program, uhh, they do though \$\endgroup\$
    – Jo King
    Commented Mar 6, 2020 at 0:33

Turing Machine Code and Whitespace, 85 bytes


 	 0 _	a	r 1 ; ; ;	;
 1 _ b r 2	;	; ; ; ;	; ;
 2 _ c * 3	;	; ; ; ;	;	;
 ; ;

Works in Turing Machine Code
Errors in Whitespace: Prelude.!!: index too large


Works in Whitespace
Errors in Turing Machine Code: Halted. No rule for state '0' and symbol '_'.

Takes advantage of the fact that Turing Machine Code ignores most white space and Whitespace pretty much ignores everything else.


GolfScript / MathGolf, 15 bytes

Here is a golfing language one in pure ASCII. (I guess the best score possible is 15 bytes...)

"abc"#; " a b c

Try it online!

GolfScript explanation

"abc"           # Start a string
     #          # Create a comment (rest is a comment)
      ; " a b c

MathGolf explanation

"abc"           Start a string
     #;         Perform expoentiation between the string and the input (implicitly a string)
                This isn't defined yet, so it throws an error
                Discarding the value won't be executed
        " a b c So does this

MathGolf/GolfScript, 8 bytes


Try it online!

MathGolf Explanation

"b";     # Push b and then discard the value
    "abc # Push abc and then implicitly print

GolfScript explanation

"b";     # Push b and then discard the value
    "abc # Unterminated string, throws an error

Rust / Python 3, 70 bytes

Full (Rust)

const _:i8= 3;//1 ; p r i n t ( " a b c " ) #
fn main(){print!("abc")}

Skipped (Python):

cnt_i=3/1;print("abc")#f an)pit(ac)

Rust fails on the skipped version with

error: unexpected closing delimiter: `)`
 --> a.py:1:28
1 | cnt_i=3/1;print("abc")#f an)pit(ac)
  |                            ^ unexpected closing delimiter

error: aborting due to previous error

And Python fails on the full version with

  File "a.rs", line 1
    const _:i8= 3;//1 ; p r i n t ( " a b c " ) #
SyntaxError: invalid syntax

The Rust comment is turned into a division when one of the slashes disappears; the rest is fairly straightforward. I also avoided a compiler warning by naming the useless variable ‘_’.


Python 3 and Befunge-98, 36 bytes

z= print("@ , , , ""a b c "[8: :2] )

Works in Python:

z= print("@ , , , ""a b c "[8: :2] )

         "@ , , , "                  #String literal
                   "a b c "          #The second string literal is concatenated to the first
                           [8: :2]   #Extract every other character starting from index 8, which gives us "abc"
   print(                          ) #Print that and return None
z=                                   #Assign the result (None) to the variable z

Errors in Befunge:

z= print("@ , , , ""a b c "[8: :2] )

z     #No-op
 =    #Execute "" (raises an error in both FBBI and PyFunge)

Every other character

z rn(@,,,"abc"8 2 

Errors in Python

The code is nowhere close to anything resembling valid Python syntax, so it raises a SyntaxError.

Works in Befunge:

z rn(@,,,"abc"8 2 

z                  #No-op
  r                #Reverse direction
z                  #No-op
              8 2  #Push 2 and 8 (which we don't care about) onto the stack
         "abc"     #Push "cba" onto the stack
        ,          #Print the top of the stack ("a")
       ,           #Print the top of the stack ("b")
      ,            #Print the top of the stack ("c")
     @             #End the program

05AB1E / MathGolf, 13 bytes/bytes


Try it online in 05AB1E (outputs abc).
Try it online in MathGolf (errors).

Every second character:


Try it online in 05AB1E (errors).
Try it online in MathGolf (outputs abc).


# Full program in 05AB1E:
"aabbccc"     # Push string "aabbccc"
         1F   # Loop 1 time:
           Ù  #  Uniquify the top of the stack
            ; #  Halve it (no-op on strings)
              # (after the loop, the top of the stack is output implicitly)

# Full program in MathGolf:
           Ù  # Errors during compilation, because `Ù` isn't part of its known character-
              # set from the MathGolf codepage

# Reduced program in 05AB1E:
"abc"         # Push string "abc"
     F        # Loop that many times, which results in an error because it isn't an integer

# Reduced program in MathGolf:
"abc"         # Push string "abc"
     F        # Push builtin integer 17
      ;       # Discard the top of the stack
              # (after which the entire stack joined together is output implicitly as result)

Ruby & Perl 5 + -M5.10.0, 29 bytes

s=a=y=$> .write  a=?a ,?b ,?c

abc in Ruby, error in Perl

This sets the variables s, a and y to the result of writeing a=?a ,?b, ?c (equivalent to 'abc' as ? defines a character literal and write accepts multiple arguments) to $> ($> points to STDOUT by default).

say$ wie =a,b,c

abc in Perl, error in Ruby

This calls say with $ wie =a,b,c, which sets $ wie to the bareword a and passes the barewords b and c.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.