Let us create a sonnet quine!

5

1

There are programs that will output its source code to standard output and do nothing else. They also access no external output. This type of program is known as a quine, and is a common code challenge.

There are poems that have the rhyme scheme a-b-a-b, c-d-c-d, e-f-e-f, g-g. They have 14 lines. They are usually recited in iambic pentameter. They are called sonnets.

You are to write a program/poem that is both a quine and a sonnet.

  1. When saying lines, it is recommended that you only say all characters except for: whitespace and ,()[]_"'. This is flexible depending on the language though.
  2. Iambic Pentameter means 10 syllables, starting unstressed, and then alternating between stressed and unstressed. This is optional, but will mean more votes.
  3. Comments are discouraged, especially to complete rhymes (although comments are very much encouraged if they can be incorporated with the code in the poem in a way that produces dramatic effect.)
  4. Cruft is discouraged.

Voters, use the four above guidelines when voting. This is a popularity contest, so the program with the most votes wins.

PyRulez

Posted 2014-03-16T00:22:22.803

Reputation: 6 547

Question was closed 2017-06-01T01:59:14.260

I don't think that this question has lived up to our sites standards in the past 3 years. 1) There is no objective definition of sonnet, making this question rather unclear. 2) There is no judging criterion other than "most creative" making this question without a proper winning criterion. In the past it was common practice for anything to go in terms of a pop-con but that has changed. I am going to Vote to close as unclear until this challenge is clarified. – Post Rock Garf Hunter – 2017-06-01T01:32:46.867

While I undersand the intention behind giving people some leeway when it comes to pronounciation, it means that the validity of any answer is debatable, ultimately making the challenge unclear. – Dennis – 2017-06-01T01:58:41.403

@Dennis that's why its a popularity contest. – PyRulez – 2017-06-01T02:00:42.643

Popularity contest no longer means anything goes. All challenges need an objective validity criterion. – Dennis – 2017-06-01T02:01:55.410

This is too easy for languages like Javascript, which (function(){return'('+arguments.callee+')()';})() is a quine. Adding garbage after the return is enough. – Ismael Miguel – 2014-03-16T01:04:05.663

I was going to attempt this one, but the restrictions imposed by creating a quine (in most languages) make it too difficult to output any kind of meaningful sonnet. Therefore the question isn't very interesting, since the sonnet will just be rhyming characters such as / and - (slash and dash). – grovesNL – 2014-03-16T01:27:39.823

@grovesNL You could create a different sonnet challenge. – PyRulez – 2014-03-16T02:02:43.953

@IsmaelMiguel That isn't considered a quine, since you are accessing an external resource (namely, the source code.) – PyRulez – 2014-03-16T02:03:15.047

@PyRulez I wasn't trying to be rude. I'm just offering some feedback, which may especially relevant if there aren't many responses for that reason. – grovesNL – 2014-03-16T02:08:25.580

Actually, I'm reading the arguments passed to the function. From there, I access the function itself and take the source code. It accesses itself. – Ismael Miguel – 2014-03-16T02:09:24.147

@grovesNL I was serious. It would be sort of odd to completely change the question now, but if you have an idea for a sonnet challenge go ahead. I wasn't trying to be rude either. – PyRulez – 2014-03-16T02:09:42.930

@IsmaelMiguel From wikipedia, it says quines can't use input. – PyRulez – 2014-03-16T02:11:23.297

@PyRulez Is there any input in it? – Ismael Miguel – 2014-03-16T02:43:05.317

Code Challenge, Popularity Contest and Code Golf are mutually exclusive. You've described a popularity contest in the question text, so the code challenge tag doesn't need to be there. – undergroundmonorail – 2014-03-16T02:52:30.867

@IsmaelMiguel: I guess it's not a quine if the restriction is "the code cannot read its own source code in whatever manner" – Claudiu – 2014-03-16T16:39:24.777

It cannot read it's source code from external sources. The var arguments is an internal var to the function itself. – Ismael Miguel – 2014-03-17T01:07:31.230

Wait iambic pentameter is not required? So 10 syllables per line is not required? – DankMemes – 2014-06-02T15:18:47.163

Answers

5

Ruby

s = [[/t{1}he_way/,'to_a'],[/\*j{1}ewel/,'*rule']].to_a
puts <<'-'.*(2).tap { |code| s.each { |rule| code.sub! *rule } }, '-'
s = [[/t{1}he_way/,'to_a'],[/\*j{1}ewel/,'*rule']].the_way
puts <<'-'.*(2).tap { |code| s.each { |rule| code.sub! *jewel } }, '-'
-
s = [[/t{1}he_curse/,'reverse'],[/\*c{1}raze/,'*phrase']].reverse
puts <<'-'.*(2).tap { |code| s.each { |phrase| code.sub! *phrase } }, '-'
s = [[/t{1}he_curse/,'reverse'],[/\*c{1}raze/,'*phrase']].the_curse
puts <<'-'.*(2).tap { |code| s.each { |phrase| code.sub! *craze } }, '-'
-
s = [[/r{1}eject/,'collect'],[/\*b{1}ird/,'*word']].collect
puts <<'-'.*(2).tap { |code| s.each { |word| code.sub! *word } }, '-'
s = [[/r{1}eject/,'collect'],[/\*b{1}ird/,'*word']].reject
puts <<'-'.*(2).tap { |code| s.each { |word| code.sub! *bird } }, '-'
-
puts <<'-'.*(2).tap { |code| [[/\*l{1}augh/,'*half']].each { |half| code.sub! *half } }, '-'
puts <<'-'.*(2).tap { |code| [[/\*l{1}augh/,'*half']].each { |half| code.sub! *laugh } }, '-'
-

Don't pronounce the dashes, they're just there to delimit stanzas. Scansion's not perfect but decent.

histocrat

Posted 2014-03-16T00:22:22.803

Reputation: 20 600

+1 "Reverse the Curse!" would be a catchy title. I'm not crazy about the phrasing, but I got more than half a laugh out of this. – Scott Leadley – 2014-08-22T03:36:31.790