Challenge: 12 Days of Christmas

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

49 Replies - 42138 Views - Last Post: 30 April 2014 - 11:18 AM

#1 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Challenge: 12 Days of Christmas

Posted 16 December 2011 - 09:27 AM

*
POPULAR

I wanted to make a just-for-fun challenge before Christmas. I did a bit of googling and found this: http://codegolf.stac...hristmas-lyrics

Here are the rules:

Quote

Print the "12 Days Of Christmas" lyrics

Quote

On the first day of Christmas,
my true love gave to me,
A partridge in a pear tree.

On the second day of Christmas,
my true love gave to me,
Two turtle doves,
And a partridge in a pear tree.

...

On the twelfth day of Christmas,
My true love gave to me,
Twelve drummers drumming,
Eleven pipers piping,
Ten lords-a-leaping,
Nine ladies dancing,
Eight maids-a-milking,
Seven swans-a-swimming,
Six geese-a-laying,
Five golden rings,
Four calling birds,
Three french hens,
Two turtle doves,
And a partridge in a pear tree.


Rules
  • You don't have to worry about capitalization; the entire text can be case insensitive
  • You can sensibly ignore any punctuation: hyphens can be spaces, and commas and periods can be ignored
  • There should be a blank line between each verse
  • You must ordinalize your numbers: "first day of Christmas", "Four calling birds", etc
  • Shortest code wins


Have fun!

Is This A Good Question/Topic? 5
  • +

Replies To: Challenge: 12 Days of Christmas

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: Challenge: 12 Days of Christmas

Posted 20 December 2011 - 10:51 AM

This code is not particularly small, but I did do a few tricks to shorten the output as best as I can (such as by using an external file).

Spoiler

Was This Post Helpful? 1
  • +
  • -

#3 Crockeo  Icon User is offline

  • D.I.C Head

Reputation: 44
  • View blog
  • Posts: 247
  • Joined: 21-June 11

Re: Challenge: 12 Days of Christmas

Posted 20 December 2011 - 11:06 AM

While this is in the Java Programmer's section, the website doesn't mention anything about Java. So could I possibly do it in Python? (I'll also put a Java answer up too.)

This post has been edited by Crockeo: 20 December 2011 - 11:06 AM

Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: Challenge: 12 Days of Christmas

Posted 20 December 2011 - 11:32 AM

Go for it!
Was This Post Helpful? 0
  • +
  • -

#5 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Challenge: 12 Days of Christmas

Posted 20 December 2011 - 03:10 PM

Python (or any other language) is very welcome! I might not have updated my "Jack of all Languages" blog recently but I'm still working on that project so it would be great to see some other languages here.

Cheers for the entry Dogstopper!
Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Challenge: 12 Days of Christmas

Posted 20 December 2011 - 06:31 PM

This one is probably going screw with the syntax highlighter.
Spoiler

This post has been edited by AdamSpeight2008: 20 December 2011 - 06:33 PM

Was This Post Helpful? 1
  • +
  • -

#7 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Challenge: 12 Days of Christmas

Posted 20 December 2011 - 07:19 PM

Heh, nice AdamSpeight2008.

For fun, I'm going to retroactively apply a rule that all data files and embedded data, etc count towards the size of the code.

Well, I say it's for fun. It might be jealousy on my part. ;)
Was This Post Helpful? 0
  • +
  • -

#8 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Challenge: 12 Days of Christmas

Posted 20 December 2011 - 09:38 PM

cfoley: I'll name that tune in 1.
Spoiler

Was This Post Helpful? 2
  • +
  • -

#9 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Challenge: 12 Days of Christmas

Posted 21 December 2011 - 03:59 AM

Cool. 879 characters with he whitespace stripped. ;)
Was This Post Helpful? 0
  • +
  • -

#10 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Challenge: 12 Days of Christmas

Posted 21 December 2011 - 05:13 PM

Nemerle Version:
Core Part is ~544 chars (630 with surround)

Spoiler

Was This Post Helpful? 1
  • +
  • -

#11 TabwithMtnDew  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 7
  • Joined: 11-December 11

Re: Challenge: 12 Days of Christmas

Posted 21 December 2011 - 05:14 PM

I am fairly new to coding and the site but I just wanted to try.
Spoiler

Was This Post Helpful? 2
  • +
  • -

#12 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Challenge: 12 Days of Christmas

Posted 21 December 2011 - 05:22 PM

TabwithMtnDew: I'm not sure if that produces the list of presents, for each verse.

But any how, welcome to the foray. :gunsmilie:

This post has been edited by AdamSpeight2008: 21 December 2011 - 05:23 PM

Was This Post Helpful? 1
  • +
  • -

#13 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Challenge: 12 Days of Christmas

Posted 21 December 2011 - 07:34 PM

530 Char
Spoiler

Was This Post Helpful? 1
  • +
  • -

#14 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 864
  • View blog
  • Posts: 2,308
  • Joined: 28-March 11

Re: Challenge: 12 Days of Christmas

Posted 21 December 2011 - 08:12 PM

Ok, my take... 121 lines, 3934 characters including spaces/tabs/CRLF, 3.5kb console app.

Attached File(s)


Was This Post Helpful? 2
  • +
  • -

#15 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1156
  • View blog
  • Posts: 2,538
  • Joined: 05-May 05

Re: Challenge: 12 Days of Christmas

Posted 21 December 2011 - 10:45 PM

Good challenge, cfoley. I needed something to hone my regex skills. 680 stripped in Java.

Spoiler

This post has been edited by blackcompe: 21 December 2011 - 11:20 PM

Was This Post Helpful? 1
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »