Write a Quine in Plain English

41

5

Write a quine that consists of real English words separated by single spaces. A "word" is defined as a string containing only lowercase and uppercase letters (/[a-zA-Z]+/ in regex). To be "real" your word must be recognized by the official Scrabble dictionary.

I'm using the Scrabble dictionary since it gives a definitive answer on what is and isn't valid. There are too many gray areas with a normal dictionary. Note that "A" and "I" (not to mention "quine") are not valid scrabble words.

Since writing a quine only using letters and spaces is close to impossible in most programming languages, you have the option to replace the single spaces between words with a character of your choice. You also have the option to append characters to the front of the first word and the end of the last word. These added characters may be anything (including newlines and non-ASCII) except letters (a-z, A-Z). There is a penalty for adding them though (see Scoring.)

Details

  • As usual, the quines may not read or access their own source code. (I'd say that HQ9+'s Q command violates this.)
  • Output should go to stdout or a similar alternative. There is no input.
  • The words do not need to be capitalized correctly. They can have caps and lowercase anywhere. The sequence of words does not need to make any sense.
  • No word may be used more than 3 times in your program. Differently capitalized words are still the same word (e.g. 'DOG', 'dog', and 'dOg' are all the same word).
  • Using languages like PHP or HTML that can just cat out their contents is considered a trivial loophole and is not allowed.
  • The program must contain at least one word.

Scoring

Your score is the number of "real words" in your program plus these penalties:

  • +1 for every space that was replaced with another character
  • nn for every n characters you added before the first word (yes, that's n to the power n)
  • nn for every n characters you added after the last word

For example, the program

We all LIKE PROgraMmING

would score 4 because it contains 4 words; no characters were added or replaced any spaces. It's output would of course be We all LIKE PROgraMmING.

The program

!We@all LIKE#PROgraMmING- =

would score 4 + 2 + 1 + 27 = 34; 4 for the words, 2 for the replaced spaces, 1 for the ! at the front, and 27 for the - = at the end. It's output would of course be !We@all LIKE#PROgraMmING- =.

The lowest score wins. Tiebreaker goes to the answer with the fewest penalty points. If there's still a tie the highest voted answer wins.

Calvin's Hobbies

Posted 2015-02-26T09:37:31.793

Reputation: 84 000

1Does that dictionary also exist as a list? That would be a lot more helpful to browse through than having to check each word individually. – Martin Ender – 2015-02-26T09:54:43.490

16Shakespeare anyone? – dwana – 2015-02-26T09:57:25.267

Is "too hard" a valid downvote reason? Because I feel this is too hard. – John Dvorak – 2015-02-26T11:10:23.277

1@JanDvorak I don't think so... The fact that I can't write anything like this shouldn't make other people see this as a bad question, it's a valid, although pretty difficult, challenge, is it not? – rorlork – 2015-02-26T11:13:03.187

7I'm still interested in a Shakespeare solution. – John Dvorak – 2015-02-26T12:05:54.790

1@JanDvorak, I'm pretty sure that's impossible without using you,your,and,as, etc. more than 3 times. – bmarks – 2015-02-27T15:13:55.377

@bmarks do you need those in a Shakespeare program? I can't see a requirement for a readable prose. I can still see why the triple occurence maximum is really problematic. In fact, in order for a character to be useful it must 1) be declared, 2) enter a scene and either 3a) speak or 3b) be spoken to, then leave. A speaker can't leave and they can't speak twice. Since Shakespeare doesn't like more than two characters on a stage, you are essentially limited to one or two monologues at most. Have fun. – John Dvorak – 2015-02-27T15:29:53.353

@JanDvorak to assign variables you need to use you/thou. To do any kind of math operation (to limit the number of added characters) you need to use as. To do any comparison you need as or than. To do jumps/gotos (there are now other looping structures), there are a limited number of words you can use. Essentially, Shakespeare would have the same problems assembly would have with the triple occurrence limit. Also, the variables (characters) are not normally valid English words anyway. – bmarks – 2015-02-27T15:56:34.633

I'd like to drop the triple occurence limitation for Shakespeare, then. Even if it means I'm inegligible for winning. – John Dvorak – 2015-02-27T15:58:45.933

1@JanDvorak I'm fine with a Shakespeare submission that breaks that rule. Though to be fair it wouldn't be allowed to win. – Calvin's Hobbies – 2015-02-27T22:18:32.777

Can we instead opt to omit the space between two words, instead of replacing it with another character? – AJMansfield – 2015-02-28T14:56:43.420

This is an exceptionally difficult challenge. – AJMansfield – 2015-02-28T18:58:07.497

If you have enough rep and want to sort by activity, open in private browsing (or Incognito, or InPrivate, whatever) mode helps. (Can't vote, though.) – jimmy23013 – 2015-02-28T21:52:38.780

@user23013 or you could just click the "active" link to sort by activity? – user253751 – 2015-03-01T04:46:39.533

@immibis To hide so many deleted answers (which are already more than valid answers) after 2k rep. – jimmy23013 – 2015-03-01T04:58:54.243

@AJMansfield Sorry, no. It'd be unfair to make that a rule now since the challenge has been out for a while. – Calvin's Hobbies – 2015-03-02T05:53:04.903

Is the string literal "programming" in php code. (i.e) the word programming by itself as answer completely valid? Is that a loophole? – Rohan Jhunjhunwala – 2016-07-07T01:54:52.100

Oh missed that distinction my bad! – Rohan Jhunjhunwala – 2016-07-07T01:56:49.580

@JanDvorak my SPL answer definitely breaks the repetition rule. I doubt a quine is possible with the basic dictionary of allowed words in SPL, but if you manage to create one, I would love to see it. – Flogo – 2017-03-18T08:39:48.120

Can I treat a part that contain words as some replacement? – l4m2 – 2018-04-07T01:15:03.427

Are error quines okay? https://codegolf.stackexchange.com/a/96018/59376

– Magic Octopus Urn – 2019-01-31T18:43:54.687

Answers

25

golfscript, 8 words + 8 symbols = 20 16 (3?)

{four"words.written~twice"four}words.written~twice

The words are just a filler, the core is a tiny quine core:

{".~"}.~

Duplicates and evaluates a function that just appends the instructions to duplicate and evaluate itself. When a function is printed, it is stringified automatically. This is the smallest quine that does something.

Or we could just use a function literal that never gets evaluated. But it feels like cheating...

{whatever}

John Dvorak

Posted 2015-02-26T09:37:31.793

Reputation: 9 048

You don't need concatenation. {a`b"x.y~z"c}x.y~z – Dennis – 2015-02-26T15:47:04.127

@Dennis I don't even need the inspection in that case. Thanks! I feel like I need to ask the OP something... – John Dvorak – 2015-02-26T16:36:57.453

The rules say that the quines may not read or access their own source code. Your solution might violate that. – Cephalopod – 2015-02-26T16:38:42.097

8@Cephalopod I don't read my own source code. I'm just pushing a function onto the stack and the runtime prints it out for me, blissfully unaware of the fact that the entirety of my source code is a function literal. – John Dvorak – 2015-02-26T16:41:34.533

1I think the {whatever} would violate the too-trivial rule ("Using languages like PHP or HTML that can just cat out their contents is considered a trivial loophole and is not allowed.") – Claudiu – 2015-02-26T19:38:58.577

1@Claudiu that's a rule against languages, not solutions. That's why I asked. – John Dvorak – 2015-02-26T19:55:54.197

@JanDvorak: That's a good point – Claudiu – 2015-02-26T20:25:08.993

{whatever} is like 1 in a repl – l4m2 – 2018-04-07T01:10:04.100

54

><>, 25 words + (22 + 11 + 11) extra = 57 49

Oh god, my brain.

'brr3deep*clap6beep+orb5flap*leap4deep+clap5beep5flap*leap9deep9clap*beep+flap0placed apple alp0leap=clip?lob8blip*flip0clip.

Since the rules state "There is no input.", for this program to work you'll need to pipe in an empty file.

Oh and yes, brr is a valid Scrabble word, as are tsktsk and pfft.

Explanation

First of all, the following words are no-ops:

deep clap beep flap leap clip blip flip

This is because of two reasons:

  • abcdefl push numbers (10, 11, 12, 13, 14, 15 and the length of the stack respectively). In addition, i pushes -1 if EOF is met, seeing as there is no input.
  • The p command pops three chars v,y,x and places v at the position x,y.

Yes, ><> lets you modify the source code on the fly! We don't really make use of that though, as we only need the p for popping.

If we get rid of these no-ops, we get:

'brr3*6+orb5*4+55*99*+0placed apple alp0=?lob8*0.

In a similar way, the laced app part of placed apple and the e alp part of apple alp are also no-ops, and the rr of brr just reverses the stack twice, which we can also remove:

'b3*6+orb5*4+55*99*+0pl0=?lob8*0.

Finally, something that looks like a regular ><> program! The idea is to make use of the standard ><> quine, which works like so:

  • The initial ' starts string parsing, pushing every char met until we hit another '
  • We keep pushing chars until the end of the line, at which point we wrap the instruction pointer back to the start (since ><> is toroidal)
  • We land on the initial ' again, and stop string parsing. The result is that we've pushed every single char in the program (except the initial ') onto the stack.

Then the following happens:

b3*6+o                Print the initial ' quote (ASCII 39)
r                     Reverse the stack
b5*4+                 Push a ';' (ASCII 59)
55*99*+0p             Replace the 'l' of 'lob' with ';'

(print loop)
l0=?;                 If the stack is empty, terminate. Otherwise...
o                     Print the top of the stack
b8*0.                 Jump back to the beginning of the loop

Sp3000

Posted 2015-02-26T09:37:31.793

Reputation: 58 729

"No word may be used more than 3 times in your program. Differently capitalized words are still the same word (e.g. 'DOG', 'dog', and 'dOg' are all the same word)." Anyway you get an upvote from me, sir. – rorlork – 2015-02-26T12:01:46.983

@rcrmn I kept adding so many words I completely forgot about that rule! Fixed now, although I did want to avoid having to use i. – Sp3000 – 2015-02-26T12:05:45.367

"leap" should be an option, too. How about "loop", what does o do? – John Dvorak – 2015-02-26T12:08:32.353

@JanDvorak "leap" is already in there, and o prints the top of the stack. Unrecognised chars throw an error in ><>, which is also pretty annoying here... – Sp3000 – 2015-02-26T12:10:10.467

1TIL "pa", "la" and "be" are valid words in Scrabble – John Dvorak – 2015-02-26T12:17:50.713

20Reading your program aloud makes me imagine what punch card computers must have sounded like. – Calvin's Hobbies – 2015-02-26T19:35:39.523

@Calvin'sHobbies I'm glad I'm not the only one who was hearing imaginary machine noises like that as I read it. – mbomb007 – 2015-02-26T21:22:05.017

10I think you've stolen that program from the source of R2D2's operating system. – ceased to turn counterclockwis – 2015-02-28T13:07:17.880

Since there’s laxer rules on ending programs with an error now, you can do something like "clap:clap1clap-or>or# – Jo King – 2018-04-07T00:18:13.850

21

Chicken, 1 word

I'm not normally into esolangs, but this one seemed perfect for this. I think this is a true quine:

chicken

Pushes 1 chicken to the stack. The stack is then displayed.

Digital Trauma

Posted 2015-02-26T09:37:31.793

Reputation: 64 644

1This (and the Julia answer) border on trivially invalid. You can keep them here but no promises on accepting. – Calvin's Hobbies – 2015-02-27T00:05:42.087

@Calvin'sHobbies In the interests of fairness I will happily delete this if you feel it is too loopholey - Your call. I was working on an applescript solution, but got frustrated by the "No word may be used more than 3 times" rule which seems to make this especially hard. So I went for the cheap trick instead :-) – Digital Trauma – 2015-02-27T00:45:54.953

@Calvin'sHobbies: I'm the author of the Julia submission. I ditto DigitalTrauma's sentiment on removing my post if you feel it's too borderline. I also did R. Is that too close as well? – Alex A. – 2015-02-27T03:30:26.120

@Alex and DT: It's up to you guys. I probably won't accept either answer but I don't mind them being here. I'm still kinda torn on the R answer, though the idea is pretty much the same as the Julia one... – Calvin's Hobbies – 2015-02-27T03:36:58.120

12

R, 2 words + 1 replacement + 1¹ trailing = 4

Objects which aren't assigned to anything are just printed to stdout. Since an expression is an object, the following code prints itself:

expression(puppy)

Previous submission, 5 points:

function(hello)hello

Alex A.

Posted 2015-02-26T09:37:31.793

Reputation: 23 761

You were inspired by my cheaty 3-point solution, weren't you? ;-) – John Dvorak – 2015-02-26T16:51:36.853

1@JanDvorak: I actually didn't see that before I posted this, but it is now a retrospective source of inspiration. – Alex A. – 2015-02-26T16:53:26.413

12

Python 2, 58 = 37 words + 21 punctuation marks

programming=puzzle=hash and'fear=coerce and"programming=puzzle=hash and%rif reload else fire;exec prog"or English;ramming=None or"ramming"if license else pirate;print fear%puzzle+ramming'if reload else fire;exec programming

With some newlines added:

programming=puzzle=hash and'fear=coerce and"programming=puzzle=hash
and%rif reload else fire;exec prog"or English;ramming=None or
"ramming"if license else pirate;print fear%puzzle+ramming'
if reload else fire;exec programming

The three uses per word restriction was what made this one difficult to write. I wanted to use the string with all the code more than 3 times, and every string had to be insulated with if else and or operators which I only had a limited supply of.

feersum

Posted 2015-02-26T09:37:31.793

Reputation: 29 566

@user23013 Oops, forgot to replace it with a random identifier. – feersum – 2015-03-01T05:46:47.933

7

Julia, 1 word + 1¹ preceding = 2

Julia has objects called symbols which are defined using a preceding :. Much like my R solution, this just prints when submitted.

:puppy

Alex A.

Posted 2015-02-26T09:37:31.793

Reputation: 23 761

5

DOS command line, 10

& was unexpected at this time.

Error quine, not banned it seems

l4m2

Posted 2015-02-26T09:37:31.793

Reputation: 5 985

1This code doesn't "encode" any part of the code. See our definition for a quine – MilkyWay90 – 2019-01-31T03:49:17.893

@MilkyWay90 Using the definition & encodes the whole code and stop outputting – l4m2 – 2019-01-31T08:35:57.847

Oh, can you edit the answer so I can remove my downvote – MilkyWay90 – 2019-01-31T14:06:26.310

1Interesting loopholey answer...is & a word, though? – Redwolf Programs – 2019-01-31T21:20:39.493

@RedwolfPrograms no, but & is two symbols. 5 (words) + 1 (trailing) + 2^2 leading = 10. – Draco18s no longer trusts SE – 2019-02-01T01:30:05.913

Okay, I upvoted. You can remove the quote now – MilkyWay90 – 2019-02-07T02:17:28.893

3

Runic Enchantments, Score 4+3+11+11 = 9

"hOt3OX4NOt+kNOt@

Try it online!

Words: hot ox not knot (4)
Replacements: 3 4 + (3)
Before: " (1)
After: @ (1)

All of the characters GNOQWghtxz are no-op in Runic (as well as space and period, but more spaces doesn't help scoring). Including the X and k required for functionality, this gives the following available word list:

5 Letter Word(s)
  thong
4 Letter Word(s)
  gong goth gowk gown hogg hong honk howk knot know nogg nowt tong town wonk wont zonk
3 Letter Word(s)
  got gox hog hon hot how nog noh not now nth own tho tog ton tow two who wok won wot
2 Letter Word(s)
  go ho no oh on ow ox to wo

I cherry picked based on the needs of the space it was going into and making it sound funny.

Removing all NOP characters gives the following quine:

"3X4+k@

Try it online!

Draco18s no longer trusts SE

Posted 2015-02-26T09:37:31.793

Reputation: 3 053

0

huh? - 1 word + 1**1/1^1=1 char after the word = 2 total score.

Ouch!

Ouch! is a valid quine in huh?

Run it like pythuhn.py Ouch!, and there cannot be a file named Ouch! in the current directory.

MilkyWay90

Posted 2015-02-26T09:37:31.793

Reputation: 2 264