12
1
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
Scoring
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.
Is trailing whitespace allowed in the output? – Arnauld – 2019-10-25T15:17:49.513
2
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.
– FryAmTheEggman – 2019-10-25T17:46:05.7331Are 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. – gastropner – 2019-10-30T00:50:40.050
Can we output in uppercase (
ABC
instead ofabc
)? – Grimmy – 2019-10-31T13:45:43.550