Thursday 23 December 2010

#CarolsInCode - Top Five Countdown

#carolsincode
#CarolsInCode is a programming meme with a seasonal twist. Short programs are used to encode the lyrics of a Christmas carol. Some display the lyrics when the program runs while the more ingenious examples define the song with the program's control structures.

For example in JavaScript:

while ( shepherds.watch() == 'flocks' &&
  date.getHours() in night )
{
  lord.angel--;
  glory.shone_around();
}

This is While Shepherds Watched Their Flocks by Nahum Tate:

“While Shepherds watch their flocks by night,
All seated on the ground,
The angel of the Lord came down,
And glory shone around.”

Here's the top five countdown of the very best #CarolsInCode. Can you identify all five? Is your favourite missing?

GrumpyWookie:

Weather.Outside="frightful";
Fire.Delightful=true;
Lights.Luminosity=WayDownLow;
for (int i=1; i<=3; i++) { LetItSnow(); }

ShinyEmptyHead:

public Sleigh sleigh;
public void dashThroughSnow()
{
int horses = 1;
sleigh = new Sleigh(horses);
for (Field field : fields)
{
laugh();
}
}

JohnGirvin:

var wenceslas = new Person({
    rank: 'king',
    alignment: 'good'
});
$.bind(FeastOfStephen, function() {
    wenceslas.lookOut();
});

Costall:

if (DateTime.Now()=="25/12/2010")
{
for (i=0;i<3;i++) Ship[i].Visibility = Visibility.Visible;
}

GrumpyWookie:

Kiss.PersonA="Mummy";
Kiss.PersonB="Santa";
Kiss.Witness=Me;
Kiss.Location=Mistletoe.Underneath;
Kiss.Time=Date.LastNight;

More #CarolsInCode




#songsincode, lyrics for programmers

2 comments:

  1. I'm just learning Scala, but here are 2 attempts:

    ye filter _.faithful foreach _.come

    field.shepherds filter _.poor map _.lay foreach angels say noels.head

    ReplyDelete
  2. Eeeep! I think I'm in over my depth! But I'll try the Christmas songs
    1. Let it snow
    2. Jingle Bells
    3. Good King Wenceslas
    4. I saw three ships??
    5. I saw mummy kissing Santa Claus

    Thanks for your visit to my Derwentwater post.

    ReplyDelete

Note: only a member of this blog may post a comment.