29
2
The prospect of this challenge is:
- If your program is run normally, all of the code in the speech marks (
"
- double quotes) should be printed. - If your program is wrapped in double quotes (in turn inverting the speech marks), the code that is normally not in quotes should be printed.
E.g:
Let's say you have the following code:
fancyStuff("myCode"); "I like".isGreat();
If I run it, I would expect an output of:
myCode
I like
However, if I wrapped it in quotes, I would get:
"fancyStuff("myCode"); "I like".isGreat();"
When this code is run, the expected output would be:
fancyStuff(
);
.isGreat();
Obviously, the above example is not a functional response in any language. Your job is to write the code that performs in this way.
Rules
- Standard loopholes apply.
- The printed values, in both quoted and unquoted forms, must be non-empty, or consist solely of whitespace. This also means that all programs must include at least one set of quotes.
- However, trailing/preceeding whitespace is allowed.
- No looking at your own code, required file names, etc.
- Unmatched quotes are disallowed
- If there are multiple strings, they can either be printed as newlines (as in the example), or in some other human-readable way - no arrays or objects
- This is code-golf, so shortest answer in bytes wins.
Are unmatched quotes allowed, and if so, how should they be handled? – negative seven – 2019-06-20T15:24:42.797
Must the output be split with newlines like in the examples? – Erik the Outgolfer – 2019-06-20T15:27:48.633
@negativeseven no, I'll say they're not allowed. – Geza Kerecsenyi – 2019-06-20T15:29:07.803
@ErikTheOutgolfer I've updated the rules a bit, see now. – Geza Kerecsenyi – 2019-06-20T15:32:01.527
3@GezaKerecsenyi So, is a separator required, or can we simply concatenate the strings? – Erik the Outgolfer – 2019-06-20T15:32:41.127
@EriktheOutgolfer No separator is required - the only condition is that the output be a string format. – Geza Kerecsenyi – 2019-06-20T15:36:53.013
Let's say my program starts or ends with a double quote, does the program wrapped in double quotes has to output an empty leading/trailing item, or are they optional? – Kevin Cruijssen – 2019-06-20T15:41:45.953
@KevinCruijssen If you decide to separate quotes with newlines, yes, an empty line is required. But if you concatenate them, it won't make a different anyway. – Geza Kerecsenyi – 2019-06-20T15:43:21.357
Can we use single quotes or backticks instead of double quotes? – Shaggy – 2019-06-20T19:36:52.737
@Shaggy you can use them in your code, but for purposes of standardisation, the 'strings' that need to be printed should be in double quotes. – Geza Kerecsenyi – 2019-06-20T19:45:38.437
9How is an array not a human readable format? – Post Rock Garf Hunter – 2019-06-20T20:02:13.407
@SriotchilismO'Zaic It's not a string. Some consoles could even render it as
[object]
if you just try to print it. Further, arrays are made for data storage; strings are made for no reason other than human readability, so they are more primarily for that purpose. I'm only counting strings/integers/floats (but in this case just strings are relevant) as human-readable. – Geza Kerecsenyi – 2019-06-20T20:32:20.1604Must strings be output in the same order they appear in our code? – Shaggy – 2019-06-20T20:55:36.020
1I think this would have been slightly more complex if you had to print whatever was not in the quotes – Jo King – 2019-06-21T07:05:11.837
@JoKing good idea - could I make a new challenge (like part 2) about that? – Geza Kerecsenyi – 2019-06-21T07:09:48.170
@shaggy yes, they do. – Geza Kerecsenyi – 2019-06-21T07:10:20.950