Limerick Hello World

28

6

A rhyming program you write
Attempting to win the fight
For winning the contest and vote
It must compute "Hello World"
Then print it very polite

The most popular poem will win.

The requirements are:

  • The poem should be of 5 lines with rhymes AABBA
  • It can print whatever you want, but the output should contain "hello world" (uppercase/lowercase does not matter, quotes not included in the output)
  • Symbols are read aloud. For example, the fourth line above is read: It must compute quote hello world quote
  • Post below your code, on another code preview, the "read-aloud" version of your code for disambiguation on special symbols.

Excluded are poems:

  • including dead code, or characters which could be safely removed without changing the rhymes or the functionality
  • Using comments as a way to rhyme (except if there is a good reason for that)
  • using the same symbol as end of phrase for rhyme.

In case of a tie, programs outputting a poem will win. If there is still a tie, shorter programs will win.

New lines do not count. spaces, tabs and newlines are not read aloud. For example, "Hello, world!" would be read aloud "double-quote hello comma world exclamation point double-quote".

Mikaël Mayer

Posted 2014-03-04T15:32:45.413

Reputation: 1 765

Question was closed 2017-11-11T21:36:00.940

I'm voting to close this as too broad because there is no way to objectively determine if an answer is valid. – Post Rock Garf Hunter – 2017-11-11T20:01:19.583

The whole program needs to be of five lines? Can't an answer simply be the snippet of required commands? Excluding the class/function declarations and all? – mikhailcazi – 2014-03-05T11:10:40.257

Yes, the whole program needs to be of five lines. Try to spread your definitions and includes along lines. Most PL have a way to include multiple sentences on a single line with the semi-colon or similar. – Mikaël Mayer – 2014-03-05T12:21:04.810

I see that many of the answers are attempting to produce limericks, because you mention that word in your title, but not in your requirements. – TRiG – 2014-07-02T11:22:25.160

That's true. I only want the program to be a limerick. – Mikaël Mayer – 2014-07-02T12:39:18.393

Answers

86

Whitespace

A rhyming program I	wrote  	   
	
     		  	 	
	
this poem of whitespace and bloat		 		  
	
     		 		  
	
because newlines don't count  		 				
	
     	     
	
despite the amount   	 	 			
	
     		 				
	
so deserves your sincerest upvote 			  	 
	
     		 		  
	
     		  	  
	
  


Wikipedia: Whitespace (programming language)
Online Interpreter to Test Answer

Output:

Hello World

grovesNL

Posted 2014-03-04T15:32:45.413

Reputation: 6 736

3This somehow reminds me of the Beatles' Come Together. – user12205 – 2014-03-04T20:54:50.740

7It's certainly "over me" – Sideshow Bob – 2014-03-04T23:52:51.653

..... Shoot me. – ATfPT – 2014-03-05T16:21:47.640

6Excluded: Using comments as a way to rhyme – Not that Charles – 2014-03-05T17:23:06.517

2Well, I forgot that other chars were comments in whitespace. I don't think I will keep this rule because else this would ruin this winner. – Mikaël Mayer – 2014-03-05T18:15:09.890

3@MikaëlMayer I think you should keep the rule. I suspect a lot of these votes are mostly from people who are just discovering the charm of Whitespace. Personally, I'm more interested in seeing answers in the spirit of the actual challenge of rhyming code. – Jason C – 2014-03-06T09:35:05.507

1Well, even HTML and javascript use comments to rhyme... so I would say if using comments is justificable, then it's ok. In the Whitespace case, the language itself cannot have any rhymes so comments are necessary. – Mikaël Mayer – 2014-03-06T12:06:15.937

@JasonC It's debatable whether or not the characters are "comments" as they're just invalid, ignored characters... There is no comment constructor. – grovesNL – 2014-03-06T15:07:03.400

1@grovesNL That is true, or at least, it would probably hold up in court! (P.S. Weirdest trial ever.) – Jason C – 2014-03-06T15:10:03.010

60

HTML

<html>
<body><span
    class="poem"
    > Hello World! I'm a goat
</span></body></html><!-- Pecan -->

I had to get a little liberal with pronunciation of the last line. I hope it doesn't break the rules. It's also not 100% valid per W3C, but works in most browsers.

<!--
less than aich tee em el greater than,
less than body not equal to span,
class equals quote poem end quote,
greater than Hello World Bang I'm a goat
close span close body close root comment pecan
-->

cobaltduck

Posted 2014-03-04T15:32:45.413

Reputation: 741

4+1 for clever re-pronunciations... + "Bang, I'm a goat" comment... – WallyWest – 2014-03-04T22:32:37.333

5+1 for reading >< as "not equal" – John Dvorak – 2014-03-05T18:42:48.327

3A newbie a poem he wrote-a/ Hoping to get just one vote-a/ And now in this race/ He's in second place!/ With as much rep as several years on StackOverflow-ta. – cobaltduck – 2014-03-06T14:44:31.973

26

Javascript

I know this isn't within the rules, but I couldn't resist

var girl, attractive = true;    // There once was a beautiful girl
var boy; girl = ' World';       // And a boy who thought she was his world
boy = 'Hello' + girl;           // When the boy said hello
if (boy != attractive)          // She said 'my goodness no!'
    alert(window['boy']);       // And the boy through the window she hurled.

Wossname

Posted 2014-03-04T15:32:45.413

Reputation: 377

4Creative and ingenious. – Damon Swayn – 2014-03-06T07:49:45.140

3There was no need to redefine girl on the second line but I still love it. – howderek – 2014-03-06T19:44:39.087

23

Python

a = [
'hello world']
print ''.\
join(a##
)

or,

a equals open square bracket
quote hello world quote close square bracket
print quote quote dot backslash
join paren a hash hash
and finally close unmatched bracket

I'm voluntarily signing up to additional rules, because I think (1) that limericks should have good metre and (2) that the best ones have a surprise in the last line.

(With the ending being interpreted in plain English, I figure you can work out for yourself what kind of bracket is unmatched. As to the no dead code requirement, nothing in there can be removed without changing at least one of rhyme, rhythm or output).

Sideshow Bob

Posted 2014-03-04T15:32:45.413

Reputation: 330

One may remove a hash without changing functionality or rhyme. It does change the rhythm as you state, but the question‘s conditions are quite clear here, I think. – Keba – 2014-03-04T23:04:39.860

1As the nature of poetry is to bend rules I can live with it. That said, it's not clear to me that metre isn't part of the OP's concept of rhyme anyway. – Sideshow Bob – 2014-03-04T23:21:06.660

3Meh. Rhyming "bracket" with itself three times is just lazy limericking. – MikeTheLiar – 2014-03-06T15:30:17.120

Yeah, I feel bad about that. But it is a different symbol for each rhyme, as requested by OP. – Sideshow Bob – 2014-03-07T09:29:17.970

14

Haskell

Taking some liberties with the pronunciation of certain symbols, i.e. Tuple construction (,,) and function application ($).

main = something that we wrote
     where something x y z = bloat
           bloat = flip ($) m putStrLn
           (that,we,wrote) = undefined
           m = "hello world"

The reading is supposed to be:

main is something that we wrote
where something x y z is bloat
bloat is flip apply m putStrLine
Tuple that we wrote is undefined
misquote hello world quote.

monocell

Posted 2014-03-04T15:32:45.413

Reputation: 2 551

12

JavaScript

if (!!1) // and
  alert('&#10084; &#10084; the world') // and
Burn = $.cache
return 1 > his_parts.the_sum

If in brackets one follows exclaiming marks

and alert the world inside brackets after entity hearts

slash, slash and burn

equals cash, cash, return

one is greater than the sum of his parts

ATfPT

Posted 2014-03-04T15:32:45.413

Reputation: 221

3I don't think I know anyone who pronounces "$" as "cash," although I admit to not writing JavaScript. – Carl Witthoft – 2014-03-05T18:54:05.343

1+1 I like the non-literal transcription, and "entity hearts" is kinda funny, despite the line break liberties. – Jason C – 2014-03-06T09:40:56.437

8

BASIC

More specifically, Chipmunk Basic. The syntax rules have been stretched almost to breaking point, so it may be impossible to run this in other dialects without modification.

Source:

read hi$, u$, q
print hi$ " world how are you
  print "Or as they say
  print u$ q "day
data Hello, How R U, 2

"Read-aloud" version:

read hi string comma u string comma q
print hi string quote world how are you
  print quote Or as they say
  print u string q quote day
data Hello comma How R U comma 2

Notes:

  • There are no line numbers in the source code, but it will still load and run without any problems (see below).
  • The $ sigil is read as "string" in the context of BASIC programs (see, e.g., this Wikipedia page).

And here's proof that it does actually work:

screen grab of program running in Mac OS X

r3mainer

Posted 2014-03-04T15:32:45.413

Reputation: 19 135

How did you make this gif? – Kartik – 2014-03-06T07:09:15.060

@Kartik I used an app called IShowU

– r3mainer – 2014-03-06T08:54:24.757

6

Bash

As the answer is only forced to contain the phrase "Hello World", the easiest solution should be:

echo A rhyming program you write
echo Attempting to win the fight
echo For winning the contest and vote
echo It must compute "Hello World"
echo Then print it very polite

Keba

Posted 2014-03-04T15:32:45.413

Reputation: 211

8

Legal within the rules, but this answer is no fun at parties. http://meta.codegolf.stackexchange.com/a/1063/3363

– Jonathan Van Matre – 2014-03-04T16:56:46.693

1@JonathanVanMatre That is a sign that the problem is in the question. Anything different than just directly printing the output would be suprefluous. Further the first "excluded" rule inhibit anything more creative, even variable names with more than one char and code identing, it is a code-golf evaluated as popularity-contest, getting the worst of the two. – Victor Stafusa – 2014-03-04T17:10:15.877

@JonathanVanMatre: Agreed, but I rather think this question/problem is not very good. (Sadly enough I am unable to downvote as I lack some reputation.) – Keba – 2014-03-04T17:11:46.153

@Keba, Yes, given the restrictions is the question, I think that there is nothing wrong with your answer, the OP practically asked specifically for this. – Victor Stafusa – 2014-03-04T17:14:37.337

@Keba Downvoting is not the only way of showing your point of view to the authors. – VisioN – 2014-03-04T17:17:01.377

@VisioN: Yes, so I gave this answer. ;) – Keba – 2014-03-04T17:19:31.587

This answer is invalid - The poem should be of 5 lines with rhymes AABBA Vote and World do not rhyme. – Timtech – 2014-03-04T17:40:30.637

4@Timtech: It‘s Vote and Quote. – Keba – 2014-03-04T17:42:29.847

True, but it still violates the rules. – Timtech – 2014-03-04T18:02:31.440

2Did you consider improving the question? / That might have made a better impression. / Though the damage is done / Wouldn't it be more fun / To make a real limerick-coding confection? :) – Jonathan Van Matre – 2014-03-04T18:08:29.367

1@Victor, "characters which could be safely removed" does seem to imply that you can't use multi-character variable names except where they are part of a rhyme. That is problematic. – Jonathan Van Matre – 2014-03-04T18:11:56.270

Anyway, I upvoted your answer, because even if it is not very original and won't win the first place because others are not likely to upvote it compared to other answers, it has the merit to defy the question. – Mikaël Mayer – 2014-03-05T12:26:52.723

6

Ruby

comma = ""<<44
print "Hello" or
more = ""<<32
print comma if true
puts("World!") unless print more

Live: https://ideone.com/sirBBc

Pronounced as follows (with stressed syllables capitalized)

comma Equals quote-QUOTE cons four-FOUR
print QUOTE hello END quote OR
more equals QUOTE quote cons three-TWO  # ok, that was squished
print COMma if TRUE
puts QUOTE world QUOTE UNless print MORE

histocrat

Posted 2014-03-04T15:32:45.413

Reputation: 20 600

The m and e in both instances of more needs to be removed (ore is a valid word in that position too) – pppery – 2018-08-18T23:22:12.353

Hm, I don't think I can legally rhyme or with either or or ore. – histocrat – 2018-08-19T15:56:26.823

This wouldn't be the only example of a limerick with duplicate words – pppery – 2018-08-19T16:34:49.993

6

Java

public static void main(String[] boat
){ int i = 1.0f
  ;if(i<2
  )System.out.println
("Hello world");} //hello world wrote


public static void main paren String arr boat
paren brace int i is one-point-oh float
sem-col if paren i is less than two
paren system dot out dot print line new //for some reason it's println, not printnl
paren quote hello world quote paren sem-col brace slash-slash hello world wrote

Note that comments are not really optional in Java

Ypnypn

Posted 2014-03-04T15:32:45.413

Reputation: 10 485

The b in "boat" needs to be removed ("oat' is a valid variable name, and fits) – pppery – 2018-08-18T23:23:17.530

4

Haskell

main = print . repeat
  $ head $ lines . init
     $ "Hello \
       \World!" #
         Just where (#) = const . id

Main equals printful stop repeat
Dollar head dollar line's full stop i'nnit?
Dollar quote hello back slash
Back slashworld bang quote hash
Just where parenthised hash equals constful, stop it!

This describes, hopefully, quite well the actual behaviour of the program.

ceased to turn counterclockwis

Posted 2014-03-04T15:32:45.413

Reputation: 5 200

2

TeX

I apologize in advance, because this code does not count as a limeric if you pronounce the names of each of the individual symbols (especially if you treat each letter unto itself as a token, which perhaps you ought). I have written it this way to produce the nicest possible output, which itself comes just short of being a poem.

You could safely turn it into an answer which complies with the rules by getting rid of \it and every non-alphabetic, non-whitespace character except for the final \bye (read aloud as backslash bye) and perhaps the first ! (read aloud as bang).

A \TeX\ program I think would comply,

And I'll tell you the reason for why:

``Hello world!'' tells the setter:

{\it ``Print each subsequent letter!''}

And we terminate with \bye.

Niel de Beaudrap

Posted 2014-03-04T15:32:45.413

Reputation: 21

You should remove comas and symbols at the end of each verse to let them rhyme properly. Or put them in the line afterwards. – Mikaël Mayer – 2014-03-06T12:07:26.783

@MikaëlMayer: see the remark in my second paragraph. – Niel de Beaudrap – 2014-03-06T12:54:58.470

2

Brainf*ck

Ok, chide me now for the numerous rule violations. But I couldn't help making this.

++++++++[>+++++++++<-
]>.---.$#
+++++++..+
++.++++++++
.--------.+++.------.--------.

And the output (first violation of many: no space):

HELLOWORLD

Try it here: http://www.iamcal.com/misc/bf_debug/

The reading of it:

Eight plus left more nine plus less dash
Right more dot three dash dot cash hash
Sevén plus dot dot plus
Plus plus dot eight plus
Dot eight dash dot three plus dot six dash dot eight dash.
  • Note that the final dot in the program is placed as the period at the end of the limerick :) [second violation; this is cheap]. Also, the $ and # are ignored by the interpreter (I was very proud of myself for this line).

  • The accent on Sevén is to show the stress: seh-VEN

  • This violates the rule of using different symbols. But honestly I have a very limited symbol set and no space to add in other (ignored) characters.

  • I used all caps because those are faster to access in ASCII. I had no room for a space, unfortunately.

Finally: yes, I know the last line is terrible. Any suggestions to improve it? I'm not sure if you could compress this program anymore; maybe by storing repeated letters in their at their own positions?

baum

Posted 2014-03-04T15:32:45.413

Reputation: 129

Just realized that while this would make the code longer, unrolling the initial loop into 72 + would save some space in the limerick. But I'll keep my answer as is. – baum – 2014-03-07T21:34:55.667

2

C#

I've taken a few slight liberties with the rules as truly phonetic C variants would involve far too much use of "semi-colon" which, as we all know, isn't a particularly good rhyme for anything.

{
     string unfurled = "Hello World!";
     Console.WriteLine(unfurled);
}

open brace, string called unfurled

created to read "hello world"

console write line

the string we defined

a final brace, one that is curled

BrummiePete

Posted 2014-03-04T15:32:45.413

Reputation: 129

You can always put semi-colon at the beginning of a newline, no? – Mikaël Mayer – 2014-03-10T12:46:39.747

True, Mikael, but it makes the code look very untidy! – BrummiePete – 2014-03-10T12:57:52.947

1Between untidy and rhyming, here the point is about rhyming. Don't worry, this code is not peer-reviewed. – Mikaël Mayer – 2014-03-10T14:00:26.833

1

Batch

@echo off >dull
set /p "=Hello "<nul
set w=World
echo %w%! || Furled
del dull || cull

at echo off to dull
set slash p quote equal Hello quote from nul
set w equal World
echo percent w percent bang pipe pipe Furled
del dull pipe pipe cull

unclemeat

Posted 2014-03-04T15:32:45.413

Reputation: 2 302

Can you find another rhyme dull/dull ? – Mikaël Mayer – 2014-03-05T08:30:41.267

@MikaëlMayer it's more useless code, but yes. – unclemeat – 2014-03-05T21:27:42.530

1

Java

class Hello {public static void main
(String[] args)
{yellow = System; yellow
.out.print("Hello
world");} }

class Hello brace public static void main
paren string bracket bracket args paren
 brace yellow equals system sem-col yellow
 dot out dot print paren quote hello
world quote paren sem-col brace and brace again

Ypnypn

Posted 2014-03-04T15:32:45.413

Reputation: 10 485

1This doesn't compile. How is yellow declared? – Reinstate Monica - ζ-- – 2014-03-06T12:32:13.553

1

CSS

title>me
,body lets go party
only a stylesheet,html
:after { content: 'hello world'; font-family:Rockwell
; color: #adad20

Outputs:

title greater than me

comma body lets go party

only a stylesheet comma html

colon after bracket content colon quote hello world quote semicolon font-family colon Rockwell

semicolon color colon hashtag a dad twenty

Tested in Firefox and Chrome

chrona

Posted 2014-03-04T15:32:45.413

Reputation: 111

1

#include <stdio.h> //
void main (void){
printf("Hello, World");
//just for rhyme I say stolon
} /**/

hash include less than stdio dot h greater than double slash after a space

void main left paren void right paren left brace

printf left paren quote Hello comma World quote right paren semi colon

double slash just for rhyme I say stolon

right brace and double asterisk between slashes at the last place

Nayuta Ito

Posted 2014-03-04T15:32:45.413

Reputation: 11

Nice one for the first two rhymes, but you use twice the same symbol to rhyme (semi-colon), which is not allowed. – Mikaël Mayer – 2016-08-05T09:34:33.620

Debugged, but I guess another bug appeared. – Nayuta Ito – 2016-08-06T23:42:07.837

0

Python (3)

print('''Nose
No punctuation hear close
Hello World
Hurled and swerled
Goodbye now''')

Print open quote quote quote nose, No punctuation hear close, Hello World, Hurled and swerled, Goodbye now quote quote quote close.

aaay aaay

Posted 2014-03-04T15:32:45.413

Reputation: 71

Welcome to the site, and nice first post! – caird coinheringaahing – 2017-11-11T20:11:27.330

0

Windows Batch

The spoken words are also saved within the batch file, and skipped with the last line of actual code.

@echo off >nul
set hi=Hello World
rem Now print the string,
echo !hi!
goto :) to skip the words

at echo off, greater than nul,
set H I equals sign, Hello World,
rem Now print the string,
echo pling, H I, pling
goto smile, to skip the words

:)

Edit: You'll need delayed expansion enabled for the script to work. Use cmd /v:on and run it from there.

mackthehobbit

Posted 2014-03-04T15:32:45.413

Reputation: 314

1nul, world, and words do not rhyme. The pattern needs to be AABBA. Also the comma after string should be pronounced. – unclemeat – 2014-03-07T01:49:11.073

0

print 'the letter keys on my keyboard'
print 'are sufficient to say Hello World
print 'when I type in the dark'
print 'sitting here in the park'
print'feeling horribly,horribly bored'

user3044059

Posted 2014-03-04T15:32:45.413

Reputation: 1

Note the rules: symbols such as ' are read aloud and count as part of the rhyming scheme. Welcome to PPCG! – Jonathan Van Matre – 2014-03-06T23:54:56.597

So technically it works. It doesn't say A cannot be B. – CompuChip – 2014-03-10T13:42:05.367