Programming Dichotomies (Literally)

33

11

Consider a question written in plain English whose answer involves two reasonably accurate (but potentially clever) words or phrases that can be separated by the word 'and':

Q: What are the two sides of a coin? A: heads and tails

Q: What are the best ways to travel? A: airplane and jetpack

Q: Why is a raven like a writing desk? A: because there is a 'b' in both and an 'n' in neither

Goal

Write a program which, when run normally, outputs such a question.

When every other character is removed from the program starting with the second character and the result is re-run, the output should be whatever is to the left of the 'and' in the answer.

When every other character is removed from the program starting with the first character and the result is re-run, the output should be whatever is to the right of the 'and' in the answer.

(The 'and' itself is not output.)

Example

If the program is

A1B2C3D4E5F6G7H8I9

and its output is

What are the two sides of a coin?

Then the output of ABCDEFGHIshould be heads, and the output of 123456789 should be tails.

Rules about questions and answers

  • You may use my example questions but I encourage you to make up your own.
  • The question and the two answer parts:
    • must all be distinct
    • should be common grammatical meaningful English
    • may only contain printable ASCII (hex 20 to 7E)
  • Ideally the question will be capitalized and punctuated (but the answers do not need to be).
  • The question must be at least 30 character long and have entropy above or equal to 3.5. (Type in string, hit calculate, look for last H(X).)
  • The two answer parts (not including the [space]and[space] between them) must each have at least 5 characters with entropy above or equal to 2.
  • The word 'and' may appear in either answer part.

Rules about code

  • None of the 3 code snippets may:
    • contain comments or anything else traditionally ignored by the compiler/interpreter (don't worry about putting an extra semicolon or two in, but if you think it's a comment it probably is)
    • exit the program in mid-execution
  • The code may contain any characters, including Unicode and non-printable ASCII.
  • It may have an odd or even number of characters.
  • Output goes to stdout or a file or whatever seems reasonable. There is no input.

Scoring

Since I wan't to encourage golfed answers but I want to encourage clever answers even more, the scoring will be something in between code-golf and popularity contest:

Score = (upvotes - downvotes) - floor((bytes in code that outputs question) / 3)

The highest score wins.

(Use http://mothereff.in/byte-counter as a byte counter.)

Calvin's Hobbies

Posted 2014-08-11T00:52:04.880

Reputation: 84 000

Are there any practical uses for something like this? No disrespect intended; just curious. – voices – 2016-05-25T09:53:50.730

6Gah, this is so hard to do in a "normal" language like JavaScript. The farthest I can get is something like x0=00;;. Great challenge! – Doorknob – 2014-08-11T01:34:13.700

@Doorknob sorry to deflate your boat, but 00; is traditionally ignored by the compiler... – John Dvorak – 2014-08-11T06:05:37.817

2Seriously... "apple" has a Shannon entropy of 1.92??? – John Dvorak – 2014-08-11T06:10:53.200

@JanDvorak 00; is fine. I mainly just meant to restrict comments. – Calvin's Hobbies – 2014-08-11T06:19:19.910

4It may have an odd or even number of characters Is there a number of characters that is not odd or even? – Snack – 2014-08-11T06:27:22.677

1@Snack That lets people know that the two answer code parts don't need to have the same length. – Calvin's Hobbies – 2014-08-11T06:30:49.607

Can I write to a file as output? – Οurous – 2014-08-11T07:35:22.320

@Ourous Sure. I might as well remove the "output to stdout" restriction since it might loosen up the problem. – Calvin's Hobbies – 2014-08-11T07:42:18.553

Interesting problem...though I was enjoying it a bit more before I wound up going in the "eval" direction. Perhaps there could be a similar problem of three different outputs, that's a bit more challenging in terms of what's different about the programs, and disallowed eval of code as strings? – HostileFork says dont trust SE – 2014-08-12T15:17:56.300

I was just reading the question, and I think that your third example answer may be reversed. – Magus – 2014-08-12T22:08:05.523

@Magus How so exactly? – Calvin's Hobbies – 2014-08-13T02:17:58.687

Nevermind, got the joke. Must've been blind yesterday. – Magus – 2014-08-13T14:30:25.767

This is insane! It's hard to believe it's even possible, yet look at all the answers! – GreenAsJade – 2014-08-14T12:59:53.430

Hate to nitpick, but it's a tall order to put specific requirements on the entropy contents. Firstly, one can't talk about entropy of a message without a context involving an a priori probability distribution over the messages (and not just the observed probability of individual chars in one msg). The closest objective measurement of complexity (which is of course related to entropy) is Kolmogorov complexity, but it can not be calculated by any program, including the calculator you link to. – Morty – 2014-08-17T21:01:10.473

@Morty I know the entropy restraint isn't perfect but it seems the easiest way to ensure people don't give potentially trivial repetitive answers. – Calvin's Hobbies – 2014-08-17T21:38:49.953

@Calvin: My sympathies for that. But the wording of the question gives the impression that the requirement is for the actual entropy in the string, not the entropy using some specific calculator. Besides, the whole way this calculator works is based on a huge misunderstanding of what entropy is, IMHO. – Morty – 2014-08-18T05:16:02.190

Answers

55

Javascript (148 bytes)

Creates some nonsense literals, with the side effect of creating an alert* for the question. (the splits doing similar, but creating alerts* for each of the answers).

"';"+alert( 'What is the ideal breakfast???')+/ " ;apl=e"rbta(k"esnc"r.armebplleadc ee g g s(" ) + " \/)k;e"/+ ",t'hceo 'c)a;kye= ailse rat (lpi)e "

Splits:

";+lr('hti h da rafs??)/";p="baken".replace   (    /ke/ ,'co');y=alert(p) 

and

'"aet Wa steielbekat?'+  alert("scrambled eggs")+"\);"+"the cake is a lie"

 

Question: What is the ideal breakfast???

Answers: bacon and scrambled eggs

es1024

Posted 2014-08-11T00:52:04.880

Reputation: 8 953

4This is the kind of quality that I love about this site! Where else can you find people that can do this?? – Cruncher – 2014-08-13T14:50:18.057

1

I've taken improv classes (perhaps obviously) and I'll give you a +1 here for the humor value. But as all aperture science engineers know, we are practitioners of science...so really, the funniest part is to make a neat gun. :-)

– HostileFork says dont trust SE – 2014-08-15T13:31:40.483

29

Brainfuck (437 characters)

I have to confess that this is my first brainfuck program that actually does something meaningful. The program is highly optimized for low memory systems since it uses only 4 memory locations.

Question: What are the two main groups of trees?

Answers: conifers and broadleafs

-+[[++++++++++++++++++++++[+>++++++[+>++++++++++++<>-+]+>+-+.++++++<+<+-+]+>+++++.+>++.+-..------.-<--..-+-+-+..->.-+-+-+.+<+++.+-+-+-+-+.++++.+++.+<.+>-+++-+++-+++-++.->]]++-+[[+-+-[[+++++++++++++++[>++>+++++>+++++++<<<-]>-->>---<++.+++++++++++++++++.-------.>.<<.>.>--.<++++.<.>>++.<+++.---.<.>>.+++.<++++++++++.<.>--.------------.++++++++.+++++.<.>-------.>-----.<++++++++.>+++.<+.>--.<<.>-.---------.<.>>+.--.<-..>+.<<[<++>-]<-.<]]]]

Main loop

The program consists of main loop (which isn't really a loop since all [ ] -blocks are executed only once) and two sections.

-+[[        // let answers enter
            * SNIP interleaved answer sections *
]]
++-+[[      // let odd answer and question enter
    +-+-[[  // let question enter
            * SNIP question section *
    ]]
]]

If you want to test sections independently, you must take the main loop into account. Location 0 contains -1 in even answer, 1 in odd answer and 2 in question section.

Answer section

Even answer (odd instructions removed):

// location 0 contains minus 1 from main
// set location 1 = 10 * 10 minus 1 = 99 (c)
+++++++++++[>++++++++++<-]>-. // c
++++++++++++.-.     // on
-----.---.          // if
-.+++++++++++++.+.  // ers
<                   // goto 0 (which contains 0)
+-+-+-+-+-          // padding to match length of odd answer

Odd answer (even instructions removed):

// location 0 contains 1 from main
// set location 1 = 16 * 6 plus 2 = 98 (b)  location used for characters below 'l'
// set location 2 = 16 * 7 plus 2 = 114 (r) location used for 'l' and above
+++++++++++++++[>++++++>+++++++<<-]>++.>++. // br
---.<               // o
-.+++.              // ad
>---.<              // l
+.----.+++++.       // eaf
>+++++++.           // s
>                   // goto 3 (which contains 0)

Question section

I decided to store space to separate location because its value differs drastically from other characters. This allows space to be printed simply with <.>.

// location 0 contains 2 from main
// set location 1 = 17 * 2 minus 2 = 32 (space)
// set location 2 = 17 * 5 plus 2 = 87 (W)   location used for characters below 'r'
// set location 3 = 17 * 7 minus 3 = 116 (t) location used for 'r' and above
+++++++++++++++[>++>+++++>+++++++<<<-]>-->>---<++. // W
+++++++++++++++++.  // h
-------.>.<         // at
<.>                 // (space)
.>--.<++++.         // are
<.>                 // (space)
>++.<+++.---.       // the
<.>                 // (space)
>.+++.<++++++++++.  // two
<.>                 // (space)
--.------------.    // ma
++++++++.+++++.     // in
<.>                 // (space)
-------.>-----.     // gr
<++++++++.>+++.     // ou
<+.>--.<            // ps
<.>                 // (space)
-.---------.        // of
<.>                 // (space)
>+.--.<-..>+.       // trees
<<[<++>-]<-.<       // ? (value_of_space * 2 minus 1)

Final update

In my final update I optimized multiplications so that minimum instructions are used. Also including 'l' to second character group in odd answer section proved to be huge improvement. Single character savings in odd answer basicly meant two characters from whole program, since it also reduces padding from the even answer. I also removed couple of unnecessary instructions from here and there and I don't think I can optimize the code any further.

Mika Lammi

Posted 2014-08-11T00:52:04.880

Reputation: 1 151

23

Batch - 84

Quite proud of this one

Full program: What are two sides of a coin? (console)

echo What are two sides of a coin?  2>>xx  2>>cc&&eecchhoo  hteaaidlss  2>>xx  2>>cc

Evens only: heads ('c' file)

eh htaetosdso  on 2>x >c&echo heads 2>x >c

Odds only: tails ('x' file)

coWa r w ie faci? >x 2>c&echo tails >x 2>c

Works by redirecting the error output to a file in both cases.

Οurous

Posted 2014-08-11T00:52:04.880

Reputation: 7 916

Already thought of a way to make it shorter, but that'll have to wait till tomorrow. – Οurous – 2014-08-11T11:41:27.950

3This has the highest score so far: 12 - 28 = -16. – justhalf – 2014-08-12T03:35:45.557

20

Python - 104 96 (golfed: 76)

My solution is rather simple (and somehow readable):

"";print 'What is the color of a zebra?' ;""
paraianat= "' b l a c k '"
aparaianat="'w h i t e'"

Output:

What is the color of a zebra?
black
white

Honestly, I found the idea for the first line in bitpwner's answer.


Even more readable alternative: - 113 105 97

"";print 'What is the color of a zebra?' ;""
"p r i n t ' b l a c k '" ;"p r i n t ' w h i t e '"

Even shorter alternative: - 86 76

"";print'What is the color of a zebra?';""
"""";;pprriinntt''bwlhaictke''"""

Falko

Posted 2014-08-11T00:52:04.880

Reputation: 5 307

"chessboard" also fulfils the requirements. – Martin Ender – 2014-08-11T16:10:22.100

3@MartinBüttner Zebra. :-P – David Richerby – 2014-08-12T19:59:59.370

Oh, I like zebra. And it fits nicely into a "golfed" version with a question of exactly 30 characters. Thus I slightly modified my solution. :) – Falko – 2014-08-12T21:29:39.070

Aren't the triple quotation marks considered comments in python? – M.Herzkamp – 2014-08-14T11:19:28.880

1Triple-quoted strings are no comments, but multi-line strings. Since they are also used as doc strings, they might get confused with comments. – Falko – 2014-08-14T11:25:18.813

1The updated question is only 29 characters long. – Dennis – 2014-08-21T21:19:00.753

15

Perl 186 139 135

"";print'What are the best things in life?';""&&pprriinntt("'hceraurs ht hyeo ulra meennetmaiteiso'n s   o f   t h e i r   w o m e n ")

What are the best things in life?

"pitWa r h ettig nlf?;"&print('crush your enemies'                 )

crush your enemies

";rn'htaetebs hnsi ie'"&print"hear the lamentations of their women"

hear the lamentations of their women

Using less lengthy answers:

Perl 79 72

"";print'What are my preferred weapons?';""&&pprriinntt("'smwaocredss'")

What are my preferred weapons? (30Byte, H(X)=3.76) swords (H(X)=2,25) and maces (H(X)=2,32)

Thaylon

Posted 2014-08-11T00:52:04.880

Reputation: 1 324

15

Rebmu: 79 chars OR (37 + length(p1) + 2 * max(length(p2), length(p3)))

First I'll give a 79 character solution that asks Which languages must you learn? (entropy 4.0, 30 letters not including ?) and offers you the suggestions of Rebol and [Red]:

DD  11  DD :do dd {dd  {p{Which languages must you learn?}qt}} pp{{[RReebdo]l}}

A unique tactic available here that isn't in other languages comes from taking advantage of the fact that curly braces are an asymmetric string delimiter, that can nest legally:

my-string: {"It's cool," said {Dr. Rebmu}, "for MANY reasons--like less escaping."}

That let me produce a generalized solution, that can work effortlessly on any program that doesn't use escape sequences. The 79 character version was simple enough to shortcut, but to properly contain arbitrary program source for programs p2 and p3 you'd need the full template. Had we used that, it would have been 87 characters:

DD  11  DD :do dd {dd  {p{Which languages must you learn?}qt}} ddoo{{pp{{[RReebdo]l}}}}

The pattern for using this general form is that if you have three source texts of sequential characters of variable lengths (let's use an example like AAA, BBBBB, CCCCCCC) you can encode them as something along the lines of:

DD  11  DD :do dd {dd  {AAAqt}} ddoo{{BCBCBCBCBC C C}}

(Note: Although this pattern won't work without tweaking on programs that use escape characters, this is not a fatal flaw. Getting an unmatched left brace in a string delimited by braces requires something like {Foo ^{ Bar}...but you could easily rewrite that using the alternative string notation "Foo { Bar", and combined cases can be managed with gluing together a mixture of unescaped strings.)

So...how about an example? Once the general form was available, this 573 character program was assembled in only a couple of minutes from 3 prior code golf solutions:

DD  11  DD :do dd {dd  {rJ N 0% rN Wa1m2j S{ \x/ }D00 Hc&[u[Ze?Wa Qs~rpKw[isEL00c[skQd2k][eEV?kQ[tlQ]]pcSeg--b00[eZ 1 5]3]prRJ[si~dSPscSqFHs]eZ 1[s+dCa+wM2cNO]]]Va|[mpAp2j]prSI~w{}Ls2w Wl h01tiVsb01n -1 chRVs{}hLceVn01qt}} ddoo{{BrdSz [fcebC[sn[{N sbeo[tIt0l1eV}0e5gXN1 01L{5s0}C{1}0{0 Do5f0 0bMe1e0r0}0]]]tMw9C9 Numz Jl[paN+[KperlCJBn[[ba sWS{B noJn Nt0h0e] jw]aJlnl]}aCd{K,j } b P { . } l f E Z - - n [ N m { G o t o t h e s t o r e a n d b u y s o m e m o r e } ] { T a k e o n e d o w n a n d p a s s i t a r o u n d } c B w P l f ] ] }}

If anyone wants to try writing that program in their language of choice, and thinks they can beat 573, let me know. I will bounty you a heavy amount of reputation if you do--assuming your language of choice is not Rebmu, because I know those programs aren't minimal. :-)

That "wasteful" spacing you get at the end is what happens when p2 and p3 are of imbalanced lengths. But all 3 programs are different sizes in this case so there isn't a particular good pairing to pick for p2/p3. (I picked these because there was no external data as input, such as a maze or whatever, not that they were of similar lengths. While I could have written new programs that were more optimal, I've spent enough time and the point was you don't have to write new programs...)

How it works

(Note: I started with a more "creative" approach that was not as streamlined but more interesting-looking. I moved it to an entry on my blog as describing this approach is already long.)

A key here is the "eval code as a string" trickery like some other entries, it just has the trump card of the asymmetric string delimiter. I'll start by explaining the workings of the 80 character case.

Here's the "whole" program, adjusting the whitespace for this case's readability:

DD 11                    ; assign 11 to dd (about to overwrite again)
DD :do                   ; make dd a synonym for DO (a.k.a. "eval")

; eval a string as source code that ends with QUIT (QT)
dd {dd  {p{Which languages must you learn?}qt}}

; we'll never get here, but whatever's here must be legally parseable
pp{{[RReebdo]l}}

Here we wind up setting DD to a synonym for DO (a.k.a. "eval"). But the trick is that when the halved programs run, they wind up running code whose only effect is to define D to the harmless literal 1.

Here's what the odd-chars code makes, whitespace again adjusted:

D 1                      ; assign 1 to d
D d                      ; assign d to itself, so it's still 1
d                        ; evaluates to integer, no side effect
{d pWihlnugsms o er?q}   ; string literal, no side effect
p {Rebol}                ; print "Rebol"

And here's the even-chars code:

D 1                      ; assign 1 to d
D:od                     ; URL-literal (foo:...), no side effect
d                        ; evaluates to integer, no side effect
{{hc agae utyulan}t}     ; string literal (well-formed!), no side effect
p {[Red]}                ; print "[Red]"

It's actually the case that for the non-halved program, the dd {dd {(arbitrary code)qt}} will execute whatever code you want. However, there are two calls to evaluate instead of just one. That's because while the nested braces work great in the interleaved code, they mess up the eval behavior of DO. Because:

do {{print "Hello"}}

Will load the string as a program, but that program winds up being just the string constant {print "Hello"}. Thus the trick I use here is to take my DD (holding the same function value as DO) and run it twice. The halvers chew at the different parts of the string but they don't chew both if the even/oddness is correct for the content, and because what's left outside the string after halving is just the integral constant d they're harmless.

With this pattern there's no challenge in writing the program behavior when it's not cut in half--you can put in anything as long as the character length of the code is even (odd if you're counting the QT, which is QUIT). If you need to get the even number from an odd one, throw in a space (so there's actually a +1 in my formula above on p1 for odd program lengths of p1). The trick would seem to write that interleaved code afterwards, which must pass the parser if it isn't halved. (It won't be run because of the QT, but it has to be LOADable before it will be executed.)

This case is trivial; pp loads fine as a symbol even though it's undefined, and is split into p for print in each half program. But we can do another trick just by using a string literal again. The halved programs still have DO defined normally, so we could also have just said:

ddoo{{pp{{[RReebdo]l}}}}

By having the only part picked up by the parser in the whole case be the symbolic word ddoo and a string literal, we can then interleave any two programs we wish inside that string literal and not anger the parser. The halved versions will just say:

do{p{Rebol}}

..and...

do{p{[Red]}}

As I say, this part looks familiar to other solutions that treat programs as strings and eval them. But in the competition's case, when the programs you're packing contain nested strings, that throws in wrenches for them. Here the only things that will get you in trouble are use of escaping via carets (^)...which can be easily worked around.


(Small 'cheating' note: I added QT for "QUIT" in response to this problem. Actually, I had purposefully removed the abbreviation for quit before...because somehow I thought it was only good for console use and just taking up the two-letter space if it wasn't in a REPL. I'm adding it because I see I was wrong, not adding it for this case in particular. Nevertheless, prior to that change it would have been 2 characters longer. Also, when I first posted the solution there was a bug in Rebmu that kept it from actually working even though it should have...now it works.)

HostileFork says dont trust SE

Posted 2014-08-11T00:52:04.880

Reputation: 2 292

You actually created your own programming language? – voices – 2016-05-23T00:19:05.937

2

@tjt263 It's better thought of a code-golf "encoding" of the existing language Rebol. People have done similar things for instance with Pyth, which basically abbreviates Python. But Rebmu has a fairly interesting difference in that it's actually loadable by the Rebol parser, and "compatible". You can break into Rebol at any time in the middle of it, see for instance Hourglass. Happy to discuss it in Rebol and Red chat if you wish.

– HostileFork says dont trust SE – 2016-05-23T08:52:21.503

9

Python - 139 103

"";print'What are the ingredients for success?';""; ";" ;id=='"RUaniincboorwnss'";;pprriinntt  id++"'"'

What are the ingredients for success? -> Unicorns and Rainbows

Test:

c="\"\";print\'What are the ingredients for success?\';\"\"; \";\" ;id==\'\"RUaniincboorwnss\'\";;pprriinntt  id++\"\'\"\'"
exec c        # What are the ingredients for success?
exec c[::2]   # Unicorns
exec c[1::2]  # Rainbows
print 
print c[::2]  # ";rn'htaeteigeinsfrsces'";"";d="Unicorns";print d+''
print c[1::2] # "pitWa r h nrdet o ucs?;" ; i='Rainbows';print i+""

Old version:

# What are the ingredients for success?
"";print(('What are the ingredients for success?'));""; ";" ;"pHrEiRnEt (C'OUMnEiSc oZrAnLsG'O)"; ";" ; "p,r iTnOtN(Y' RTaHiEn bPoOwNsY'.)"
# Unicorns
";rn('htaeteigeinsfrsces')";"";print('Unicorns');"";", TONY THE PONY."
# Rainbows
"pit(Wa r h nrdet o ucs?);" ; "HERE COMES ZALGO" ;  print('Rainbows')

Vectorized

Posted 2014-08-11T00:52:04.880

Reputation: 3 486

6

Haskell, 117

Having to work with Haskell's functional paradigm means that everything has to be assigned to a variable or commented out with line -- or block {- -} comments; having nonsense functions run without assignment is out. So, to keep myself sane, I kept the question and answers as short as the rules allow.

Question: What can I not have enough of?

main=putStrLn{---}"What can I not have enough of?"{- }
=u"Scrank=e"sS"h
omeasi"n
=mpauitnS=tpru taSntprt tmLi

-----}

"Shoes" and "cakes":

mi=uSrn--"htcnInthv nuho?{ 
uSrn="Shoes"
main=putStr mi
--}
anpttL{-}Wa a  o aeeog f"-}="cakes"
main=putStr anpttL
---

N.B. The appearance of crank under "What can I not have enough of?" should not be viewed as meaningful.

comperendinous

Posted 2014-08-11T00:52:04.880

Reputation: 466

1Comments are not allowed – proud haskeller – 2014-08-11T12:27:13.047

And how the second one is valid haskell syntax? – proud haskeller – 2014-08-11T12:31:38.427

the original code has an unclosed comment block because the closing pair is in a line comment. the "cakes" code doesn't even seem like code - isn't anpttL a function? where is the = sign in it's definition? isn't it actually called anpttLWa ? – proud haskeller – 2014-08-11T12:36:43.813

@proudhaskeller Missed the rule about comments. Sorry about that. The first program does not have an unclosed comment block. It parses just fine. Line comments are meaningless within block comments. The second one is valid because line comments are valid. anpttL is a string. Take out the block comment and you'll see it equals "cakes". Wa is in the block comment, so, no, it's not actually anpttLWa. – comperendinous – 2014-08-11T12:54:45.853

oh i see now. appearently i can't parse in my head :-). – proud haskeller – 2014-08-11T12:57:54.100

2@proudhaskeller My head lets GHCi do the work on its behalf. – comperendinous – 2014-08-11T12:58:49.083

4

Lisp (76 characters)

31-character question, 6 characters in each answer ⟹ length - payload = 33

'(: (pprriinncc''fmuacghesnitaa))':(princ "What is your favorite pink hue?")

I wanted to use “What is your favorite color?”, but even stretched to British spelling, it only just reached the 30-character minimum for the question length, and I needed an odd-length question to balance the double quotes.

They say Common Lisp is verbose, but you wouldn't think so going by this one-liner. It's not even very obfuscated, you only need to insert a bit of whitespace to see what's getting quoted and what's getting executed.

Many Lisp implementations will shout out the colors, because they warp symbols to uppercase. If that bothers you, change ''fmuacghesnitaa to ""fmuacghesnitaa"".

Gilles 'SO- stop being evil'

Posted 2014-08-11T00:52:04.880

Reputation: 2 531

Because this question had a voting component, I bountied it to draw attention to try and get more votes. But the bounty has run out and as I can't give myself the points :-) I'll give it to your entry based on Rebmu's ancestor language, and encourage you to check it out if you haven't before! http://codegolf.stackexchange.com/a/36114/57

– HostileFork says dont trust SE – 2014-08-21T23:27:43.753

3

STATA 295

Question: What are the best desserts to bake right now? Answer: brownies and cookies.

Explanation: Commands in STATA are delimited by new lines.
While "//" is a comment in STATA, "///" tells the compiler to continue to the next line and include its contents in the current command.

Commands in STATA can often be abbreviated to the point where they are considered unique enough to be differentiable (so "generate" becomes "g", "global" becomes "gl" or "glo", "capture" becomes "cap", "display" becomes "di", etc.). The display command displays text to the screen. The capture command captures all errors (including syntax errors), which is why this program compiles properly.

I guess if you want to get picky, any additional "/" after the first 3 consecutive ones in a line are ignored by the compiler. Also, in the "brownies" program, technically +" " is a comment. But I claim that it still counts because the capture command would still have made it irrelevant even if it wasn't a comment.

Thanks for reading my really long explanation. Now for the code:

"What are the best desserts to bake right now?"

g   a = "g   q   /b/a/" 
g l= "b = ""b r o w n i e s "
g   c = "g   /b/a/" 
g lpo= "d = ""c o o k i e s "
g   e = "c a p  "  /////
 +  "d i ""$ b "
g   f = "c a p  "  /////
 +  "d i ""$ d "
g   g = "c a p  "  /////
 + "c a p   / / /  "+ "/ / /"
di "What are the best desserts to bake right now?"

"brownies"

g a="    ba"
gl b="brownies"
    g /// 
 p="  "       
g e="   " //
 di "$b"
    cap ///
+" "  
g g="   " //
  cap ///   +"  "
i"htaetebs esrst aergtnw"

"cookies"

    g q /// 
 ="  "        
g c="  ba"
glo d="cookies"
    cap ///
+" "  
g f="   " //
 di "$d"
    cap  ///
+ "       " ///
d Wa r h etdset obk ih o?

bmarks

Posted 2014-08-11T00:52:04.880

Reputation: 2 114

2

Ksh (82 characters)

35-character question, 5 characters in each answer ⟹ length - payload = 37

ec=\'o'(;)eehc(h)oe cChroi m$e1;; '\'
echo  What\'s the  country\'s worst problem?

I abuse the function definition syntax beyond POSIX. Dash and bash can't take it but ksh (public domain or ATT) can.

Nothing remarkable going on, just a bit of echo. Waste not, want not.

Gilles 'SO- stop being evil'

Posted 2014-08-11T00:52:04.880

Reputation: 2 531

2

PowerShell 88

"" > $x;{What is my favorite equipment?};"" >> ${x}

${XsXwXoXrXdX};;;${XsXhXiXeXlXdX}

What is my favorite equipment? (30 chars, H(X) = 4.0314)

"  x{hti yfvrt qimn?;"> {}
{sword};$XXXXXXX

sword (5 chars, H(X) = 2.32193)

">$;Wa sm aoieeupet}" >$x
$XXXXXX;;{shield}

shield (5 chars, H(X) = 2.58496)

On the full program it redirects empty strings to a nonexistent variable ${x} (the quotes for those empty strings are used to form a nonsense string that gets redirected either to an empty block {} or nonexistent variable $x on the even/odd versions), then prints the question and declares 2 unused variables (which are printed and placed next to another unused variable $XXXXXX or $XXXXXXX on the different cases).

DarkAjax

Posted 2014-08-11T00:52:04.880

Reputation: 669

1

GolfScript, 51 bytes

"Which are the sides of a coin? ".;""thaeialdss""

Output

Which are the sides of a coin? 

How it works

.; duplicates the string and deletes the copy. "" pushes an empty string. thaeialdss is undefined, so it does nothing.

Odd chars

"hc r h ie faci?";"heads"

Output

heads

How it works

; deletes the first string from the stack.

Even chars

Wihaetesdso  on ."tails"

Output

tails

How it works

Wihaetesdso and on are noops. . duplicates the empty string on the stack.

Dennis

Posted 2014-08-11T00:52:04.880

Reputation: 196 637