252
\$\begingroup\$

Write the shortest program that prints the entire lyrics of "Never Gonna Give You Up" by Rick Astley.

Rules:

  • Must output the lyrics exactly as they appear in the above pastebin*. Here's the raw dump: http://pastebin.com/raw/wwvdjvEj
  • Cannot rely on any external resources - all lyrics must be generated by / embedded in code.
  • No use of existing compression algorithms (e.g. gzip / bzip2) unless you include the full algorithm in your code.
  • Use any language, shortest code wins.

Update, 1st June 2012:
For solutions containing non-ASCII text, the size of your solution will be counted in bytes, based on UTF-8 encoding. If you use codepoints that cannot be encoded in UTF-8, your solution will not be judged as valid.

Update, 7th June 2012:
Thank you all for your awesome solutions! I'll be accepting the shortest answer tomorrow afternoon. Right now, Peter Taylor's GolfScript answer is winning, so get cracking on some improvements if you want to beat him! :)

*There is a typo in the Pastebin (line 46, "know" should be "known"). You may either replicate it or not at your discretion.

\$\endgroup\$
  • 4
    \$\begingroup\$ @w0lf You're correct. I only scanned the lyrics to verify their accuracy, I must've missed that one. I'll accept either "know" or "known". \$\endgroup\$ – Polynomial May 29 '12 at 7:30
  • 10
    \$\begingroup\$ 26k+ views in just 3 days. WOW... \$\endgroup\$ – Gaffi Jun 1 '12 at 21:30
  • 9
    \$\begingroup\$ How in the world did this generate so many views and votes? Whatever he did, I'm going to reverse engineer it. \$\endgroup\$ – PhiNotPi Jun 2 '12 at 21:27
  • 39
    \$\begingroup\$ @PhiNotPi Good luck reverse engineering "Jeff Atwood tweeting you". \$\endgroup\$ – breadbox Jun 3 '12 at 8:04
  • 9
    \$\begingroup\$ The restriction with UTF-8 makes no sense. What if my code is shorter when encoded as UTF-16 or as Latin-1? You should either count the number of bytes or the number of characters, but leave the encoding up to the author. \$\endgroup\$ – Timwi Jan 25 '14 at 0:22

63 Answers 63

0
\$\begingroup\$

Dart, 733 bytes

F(){var e=' give',a='ever gonna',l=" how I'm feeling",h=' you',i='(Give$h up)\n',j=' tell',k='(Ooh)\nN$a$e, n$a$e\n$i',b="""
N$a$e$h up
N$a let$h down
N$a run around and desert$h
N$a make$h cry
N$a say goodbye
N$a$j a lie and hurt$h

""",c="""
We've known each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it""",d="(Ooh,$e$h up)",f='I just wanna$j$h$l\nGotta make$h understand\n';return"""We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
$f
$b$c
And if$h ask me$l
Don't$j me$h're too blind to see

$b$b$d$d$k$k
$c

$f
$b$b$b""".trim();}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

C# (.NET Core), 819 816 810 808 806 792 chars/bytes

class R{static void Main(){string N="Never gonna ",r="\n",H=" how I'm feeling_",n=N+"give! up"+(N=r+N)+"let! down"+N+"run around and desert!"+N+"make! cry"+N+"say goodbye"+N+"tell a lie and hurt!_",b=n+r,w="We've known each other for so long_Your heart's been aching but_You're too shy to say it_Inside we both know what's been going on_We know the game and we're gonna play it_",f="_I just wanna tell!"+H+"Gotta make! understand__"+b,g="(Ooh, give! up)_",o="(Ooh)"+N+"give, never gonna give_(Give! up)_";System.Console.Write(("We're no strangers to love_You know the rules and so do I_A full commitment's what I'm thinking of_You wouldn't get this from any other guy"+f+w+"And if! ask me"+H+"Don't tell me!'re too blind to see__"+b+b+g+g+o+o+r+w+f+b+n).Replace("!"," you").Replace("_",r));}}

Try it online!

I'm using a mixed approach - some string concatenation, some replacement.

C# (.NET Core), 664 chars/bytes

class R{static void Main(){var a="We. n;strangers:;love[}/ rules{s;d;I^A full commitment's what I'm:hink? of[ wouldn't>et:his from1ny o/r>uy`#A+ if%1sk me&Don't:3 me%.:o;bli+:;see^**]]^$$#`**";foreach(var b in @"]^(Ooh,>-)|`^I just wanna:3%&Gotta 2u+ersta+^*|$(Ooh)!gi<, ne<r_gi<^(G-)^|*!g-!let% down!run1rou+{desert%!2cry!say>oodbye!t31 lie{hurt%^|3ell|2make% |#^We'<4n each o/r for s;long[r hear~1ch? but[.:o;shy:;s=Inside we both}wha~>o? on^We}/>ame{we._pl=|!^Ne<r_|& how I'm feel?^|_>onna |=ay it^|[^You|^
|-i<% up|% you|{1+ |}4 |4 know|~t's been|: t|;o |<ve|> g|?ing|/the|.'re|+nd|1 a".Split('|'))a=a.Replace(b[0]+"",b.Substring(1));System.Console.Write(a);}}

Try it online!

I optimized the code of another answer for this - it was using an entire class it didn't need to.

Output sample here

\$\endgroup\$
  • \$\begingroup\$ oh hey I can golf this more. +(N=r+N)+ \$\endgroup\$ – Stackstuck Mar 6 at 13:40
  • \$\begingroup\$ Saved 6 bytes with that. \$\endgroup\$ – Stackstuck Mar 6 at 14:06
  • \$\begingroup\$ Saved two bytes by adding b to f, saved two bytes by giving f a leading newline. \$\endgroup\$ – Stackstuck Mar 7 at 13:02
  • \$\begingroup\$ Saved 14 bytes w/ judicious use of .Replace(). I think it's 14 bytes. It's 14 bytes. \$\endgroup\$ – Stackstuck Mar 7 at 14:22
  • \$\begingroup\$ stole someone else's trick and optimized that: saved 39 chars/bytes over their final answer. If they steal it back I'll take this out. \$\endgroup\$ – Stackstuck Mar 13 at 10:12
0
\$\begingroup\$

ink, 839 777 bytes

~temp o="(Ooh, g{g})"
We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
->w->c->l->
And if you ask me how I'm feeling
Don't tell me you're too blind to see
->c->c->
\ 
{o}
{o}
(Ooh)
N{n}give, n{n}give
(G{g})
(Ooh)
N{n}give, n{n}give
(G{g})
->l->
\ 
->w->c->c->c->
<>
=l
\ 
We've known each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it
->->
=w
I just wanna tell you how I'm feeling
Gotta make you understand
->->
=c
\ 
N{n}g{g}
N{n}let you down
N{n}run around and desert you
N{n}make you cry
N{n}say goodbye
N{n}tell a lie and hurt you
->->
VAR n="ever gonna "
VAR g="ive you up"

Try it online!

-62 (!!!) bytes why the H E C C did I think functions were the way to go here?

It's not a very nice solution, but I spent too long on it to just throw it away.

I'm still not a huge fan of those tunnels, but assigning a multiline strings to a variable in ink is weirder than you'd think.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.