# Rock Around the Clock

In as few Unicode characters as possible, print the following (144 characters):

1, 2, 3 o'clock, 4 o'clock rock,
5, 6, 7 o'clock, 8 o'clock rock,
9, 10, 11 o'clock, 12 o'clock rock,
We're gonna rock around the clock tonight.


You must not use any numbers in your code, except the digit 1.

• There are spaces at the end of first 3 lines, do those count? Jul 17 '14 at 12:46
• @aditsu: These are due to editing, as m.buettner forgot to remove them when editing back to a code block. I would amend this, but the edit is considered too minor. Jul 17 '14 at 12:56
• I removed them now Jul 17 '14 at 13:30
• Several answers use 11. Does the instruction mean you can only use the number 1 or the digit 1? Jul 17 '14 at 16:32
• @mfvonh I said you could use 1. I didn't specify how many times, so the fact that people have used 11 is a clever loophole, and I'm all for it. Jul 17 '14 at 17:17

## Javascript - 140 132

k=1,s=", ",t=" o'clock",x="";while(k<11)x+=k+++s+k+++s+k+++t+s+k+++t+" rock,\n";alert(x+"We're gonna rock around the clock tonight.")


The fact, that 11 is made out of two 1's let me pass the rules I guess.

### Explanation

The k+++s is equal to (k++)+s, so it adds k first to x, then increments k and then it adds s to x. This process will be done three times before it adds the last sentence.

• Why do you {} ? It's not needed for the while, you have only 1 instruction. But as you have to use ";" you will win only 1 char. ^^ Jul 17 '14 at 13:18
• What does k+++s do? Is it (k++) + s or k + (++s) or (k++) + (++s)? Jul 17 '14 at 15:04
• +1 for this nonsense: x+=k+++s+k+++s+k+++t+s+k+++t+u Jul 17 '14 at 16:48
• @trlkly usually golfing in JS you have to use an output statement and alert is shorter than console.log. Using the auto display of the last calculation in console is like cheating. Jul 18 '14 at 5:03
• Are you sure that's not Brainfuck? Jul 20 '14 at 15:58

## C# - 186

Best golf language or best golf language?

class P{static void Main(){var s="";for(int i=1;i<11;)s+=i+++", "+i+++", "+i+++" o'clock, "+i+++" o'clock rock,\n";System.Console.Write(s+"We're gonna rock around the clock tonight.");}}

• I wonder why it gained so many votes, too. People like non-golfing-friendly-language entries, maybe Jul 17 '14 at 14:02
• He inspired me to do it in C++, so he gets a vote. Real Men(tm) don't use woosy interpreted languages for code golf! Jul 17 '14 at 14:56
• you don't actually need the spaces in the i++ + bits
– DLeh
Jul 17 '14 at 15:23
• I wrote it on dotnetfiddle and it didn't compile without the spaces. Thanks for pointing it. Jul 17 '14 at 15:42
• You can shave a couple more by doing WriteLine -> Write, and using a literal \n at the end of the string. Jul 18 '14 at 9:54

# Brainfuck (1574)

Not a serious submission, but follows the rules.

-[----->+<]>--.-----.------------.[-->+++<]>++.------.------------.++[-->+++<]>.[--->++<]>--.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.++[-->+++<]>+.-[--->++<]>--.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.-[----->+<]>.---------.------------.-----[->++<]>.----------.------------.----[->++<]>-.+[-->+<]>++++.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.----[->++<]>.[-->+<]>++++.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.+[->+++++<]>++.-------------.------------.[-->+++<]>+.-.----.------------.[-->+++<]>+..-[--->++<]>.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.[-->+++<]>+.+.--[--->++<]>.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.[------>+<]>.++[->++++<]>+.---[->+++<]>+.-[->+++<]>.-------------.--[--->+<]>-.++[->+++<]>+.++++++++.-..-------------.-[->+++<]>.---[----->++<]>.---.------------.++++++++.-[++>---<]>+.[->+++<]>+.--[--->+<]>---.---.++++++.-------.----------.-[--->+<]>-.---[->++++<]>.------------.---.--[--->+<]>-.+[->+++<]>.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[->++++<]>.-----.-.-----.--.+.++++++++++++.[++>---<]>.


Can be tested here.

• Brainfuck answers always deserve respect. Jul 19 '14 at 11:37
• Perhaps we should give him the "longest answer" award? #RESPECT Jul 22 '14 at 13:31

# Ruby, 100

printf"%i, %i#{", %i o'clock"*r=-~1} rock,
"*-~r+"We're gonna rock around the clock tonight.",*1..$$ • You can save another few characters with s="%i, %i#{", %i o'clock"*-~1} rock,\n" (replace the \n with a literal linebreak). Great idea to use $$! Jul 17 '14 at 19:04
• Expanding on my previous comment: If you assign r=-~1 inline, you can then use "..."*-~r instead of s+s+s, allowing you to drop the assignment to s. Jul 17 '14 at 19:41
• Very nice, will make those edits. Jul 17 '14 at 19:44

# Perl 123

$s="*, *, * o'(, * o'( ),";print"$s
$s$s
We're gonna ) around the ( tonight."=~s![(*)]!(clock,rock)[1+1+1&ord$&]||++$i!reg


The regular expression matches (, ) and *. I used the fact that the ASCII code of ( is 40, of ) is 41 and * is 42.

The r flag of the regular expression enables "in place substitution" and the e flag enables code evaluation (similar to x.replace(/.../, function(m){...}) in JavaScript).

(clock,rock) is an array of two "bare words". $& is the current match of the regular expression and ord$& is it's ASCII value.

Masked by 3 or 1+1+1 the ASCII values are now 0, 1 and 2, so I can use them to retrieve the corresponding array element. As 2 is out of the array, the "short circuit" operator || evaluates ++$i. In the first match $i is undef so incrementing it I get 1, then 2 and so on...

In simple words. This replaces * with it's current occurrence, ( with "clock" and ) with "rock".

• Does. Not. Compute. Explanation please? Jul 17 '14 at 17:29
• @TheRare Explanation added ;) Jul 17 '14 at 18:09
• It's black magic. +1 Jul 17 '14 at 18:20
• This is the kind of thing Perl was made for, unsurprising it does so well. Jul 19 '14 at 11:35

# Bash+coreutils, 120 ASCII, 92 Unicode

### ASCII:

c=clock
f(){ echo $[++i],$[++i], $[++i] o\'$c, $[++i] o\'$c rock,;}
f
f
f

# Brainfuck, 1299

Bleuuuurgh. That was terrible. I don't know why I did this, it seemed quite easy at the start. First and probably last Brainfuck script. Try it here.

With some help from an automated code generator, I was able to write a script which reused most of the characters instead of generating each one from scratch. It's only 275 characters shorter than the one automatically generated, posted here.

The output isn't newline-terminated.

I might put a bit of explanation in later on. Essentially, any long line which isn't something like >>>>>>> or <<<<<<< or >>.>>.>>.>>. generates a character or a series of them.

-[----->+<]>--.
>
++[------>+<]>+.------------.
[-]<<+.>
++[------>+<]>+.------------.
[-]<<+.>
++++[->++++++++<]>.
>
+[------->++<]>+.
>
+[------->+++<]>++.
>
--[----->+<]>---.
>
+[------->++<]>--.
>
+[------->++<]>+.
>
--[----->+<]>---.
>
+[----->+++<]>++++.
>
++[------>+<]>+.
>
++++[->++++++++<]>.
<<<<<<<<<<<<<<<<<<<<+.
>>.>>.>>.>>.>>.>>.>>.>>.>>>>.
>
+[--------->++<]>.
>
+[------->++<]>+.
>
--[----->+<]>---.
>
+[----->+++<]>++++.
<<<<<<<<<<.
<++++++++++.
<<<<<<<<<<
<<<<<<<
+.
>>>>>>>>>>
>>>>>>>>.
<<<<<<<<<<
<<<<<<
.<<+.
>>>>>>>>>>
>>>>>>>>.
<<<<<<<<<<
<<<<<<
.<<+.
>>.>>.>>.>>.>>.>>.>>.>>.>>.
<<<<<<<<<<
<<<<<<
.<<+.
>>.>>.>>.>>.>>.>>.>>.>>.>>>>.
>>.>>.>>.>>.
<<<<<<<<<<.
<.
<<<<<<<<<
<<<<<<<<
+.[-]<
++[------>+<]>+.
>>.
[-]<<[-]<
-[----->+<]>--.-.
[-]<
++[------>+<]>+.------------.
[-]<
-[----->+<]>--..
>
++++[->++++++++<]>.
>>.>>.>>.>>.>>.>>.>>.>>.>>.
>>>>>>>>>
-[----->+<]>--.+.
<<<<<<<<<
<<<<<<<<<
<<<<<<<<<
<.
>>.>>.>>.>>.>>.>>.>>.
>>>>.
>>.>>.>>.>>.
>>[-]
++[------>+<]>+.>++++++++++.
>
+[--->++<]>+.++[->++++<]>+.---[->+++<]>+.-[->+++<]>.-------------.--[--->+<]>-.++[->+++<]>+.++++++++.-..-------------.
<<<<<<<<<<
<<<<<<<<<.
>>.>>.>>.>>.
<<[-]<<[-]<<[-]<<.
>
--[----->+<]>-----.--[--->+<]>---.---.++++++.-------.----------.
[-]<<<.
>
--------[-->+++<]>.------------.---.
<<.
<<<<<<<<<<
<<.
>>.>>.>>.>>.
>>>>.
>>[-]
--------[-->+++<]>.-----.-.-----.--.+.++++++++++++.[++>---<]>.


# Lua - 217164154151149 143

Modified the old one to use a loop instead, saves a boat-load of characters. Thanks to TeunPronk for helping me shave off another 10 characters and to WilliamBarbosa for shaving off another 3 characters. 2 more characters can be saved by using the variable k. 6 more characters are saved by eliminating the variable r=" rock," since it is used once.

o=" o'clock"c=", "w=io.write k=1+1 for i=1,11,k+k do w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")end w("We're gonna rock around the clock tonight.")


Ungolfed,

o=" o'clock"
c=", "
w=io.write
k=1+1
for i=1,11,k+k do
w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")
end
w("We're gonna rock around the clock tonight.")

• I wonder if it might be shorter if you use a loop instead of j and k. Jul 17 '14 at 14:20
• @TeunPronk: haha, I was just changing that as your comment pinged me Jul 17 '14 at 14:20
• You can bring it down to 157. You dont need the comma after every 3rd number. Put the space infront of O, remove O from R, place a space in R and replace R by O,R in your io.write :) Jul 17 '14 at 14:29
• @TeunPronk: Updated. Thanks for your help! Jul 17 '14 at 14:32
• You can store io.write in a variable (f=io.write) and reduce this even further Jul 17 '14 at 15:48

# CJam - 90 ASCII / 54 Unicode

ASCII:

{{T):T}:F~", ":CFCF" o'clock":OCFO" rock,
"}Z*"We're gonna rock around the clock tonight."


Unicode:

"ξ漰㠬༳ᆧᶃ㸩씪咦⏚騤䖫퍃᰽薂ᴤਥ궋씻㱗㽫Ƶꐥ勋䎔䃱魠ꝯ朐酠礢璿狮꓈执낦덋觫ᥛ琚"GZ)#bBC*b:c~


• Your unico... "This answer has been edited." Oh, nevermind. Jul 17 '14 at 12:57

# Python (123)

print((1+1+1)*"%i, %i, %i o'clock, %i o'clock rock,\n"%tuple(range(1,11+1+1))+"We're gonna rock around the clock tonight.")


# PYG (112)

P((1+1+1)*"%i, %i, %i o'clock, %i o'clock rock,\n"%T(R(1,11+1+1))+"We're gonna rock around the clock tonight.")


# Brainfuck - 680

test it here: ideone.com/Wi9ftB

>>>++++[>+++++++++[>+++[<<<<+<+>>>>>-]<<<+<<<+<+>>>>>>-]<-]+<++++++++<+++<---------<++++++++
++++<----<++++++++++<+++[>>>+.>>>.<<<<.>>>>>>[>[<<<<<<--------.-.>>>.<<<<.>+..<.>>>.>-----.<
------------.+++++++++.+++.------------.++++++++.++++>+++++.<<<<.>.+.>>>>->>-]+<<+>-]+<[<<<<
+.>>>.<<<<.>+.<.>>>.>-----.<<.>---.+++.<.>----.++++>+++++.<<<<.>+.>>>>-]<<<<<.>>>.>-----.<<.
>---.+++.<.>----.<<<.>>>+++++++.---.<.>----.++++>+++++.<<<<<.<-]>[>>++++<<-]>>---.[-]<[>+<-]
>>++.>>-----.<+++.<.<.>++.>---.-..<------.<.>>++++.---.<++.>----.<<.>--.>+++++++.---.++++++.
-------.<+++.<.>>++++++.<++++.---.<.>--.>--------.+++.<.>----.<<.>>+++++++++.-----.-.-----.-
-.+.>[>+++<-]>-.<<<---[>>+<<--]>>--.


as i promised, here's a better version. my brain feels like.. ooh so that's where the name comes from.

explanation: (because it is unmaintainable and i don't want to forget how it works)

firstly you have to choose the best data layout for this challenge. i came up with

-4 outmost loop -3 newline char -2 space -1 numbers 1 lowercase #1 2 lowercase #2 3 comma, apostrophe, period 4 condition (outmost loop < 3) 5 inner loop 6 second inner loop

We have to belive this is optimal unless there will be too many shifts (which case you have to rearrange the layout)

After that I used a 4x9x3 loop to set the starting values for newline, number, the two lowercase letter and the comma. (all the smaller ascii codes got 4x9=36 and the two lowercase letter got 4x9x3=108, then I added and substracted some to get their real value)

When the preset is done, the code enters the outmost loop that cycles 3 times. I explain it by pseudocode.

for 3 to 1 where i = numbers
print '++i, '
while inner_loop != 0              # this is true after the first loop
while second_inner_loop != 0   # and this is true after the second
print '10, 11 o'clock, 12' # prints the difference
condition = 0              # it prevents the printing below
second_inner_loop += 1
inner_loop += 1
while condition != 0
print '++i, ++i o'clock, ++i'
print ' o'clock rock,\n'


When this section is done I just have to print the last line. But we have an uppercase W that must be produced without using too many characters. At this point we are here:

Address  Value  Pointer
-4      0  <--
-3     10
-2     32
-1     50
1     99
2    111
3     44


so I put [-3] 4 times to [-1] and substract 3 to get 87 (W): >[>>++++<<-]>>---.
then erase it [-]
and move [-2] to this location [-1] so space will be close to the lowercase letters. <[>+<-]

After that it just prints the letters. lowercase #1 is for the lower part 97-107 and lowercase #2 is for the above region.

• +1 for being 300 characters shorter than the other BF answers Jul 21 '14 at 13:13
• i was thinking about going even lower. conditions are awful to create without a decent tutorial (esolangs is down) but it can be shorter by ~200 chars more
– bebe
Jul 21 '14 at 13:26

## JavaScript, 111 107 chars, without using any number.

Execute these snippets in your browser's JS console:

107 (inspired by http://xem.github.io/obfuscatweet/ plus the other JS answer):

eval(unescape(escape('𩡯𬠨𬰽𘠬𘀢𛁴🐢𘁯𙱣𫁯𨱫𘠬𪐽𮀽𙰧𞰫𚱩🀽𜐱𞱸𚰽𪐫𚰫𬰫𪐫𚰫𬰫𪐫𚰫𭀫𬰫𪐫𭀫𘠠𬡯𨱫𛁜𫠢𚐻𮀫𘡗𩐧𬡥𘁧𫱮𫡡𘁲𫱣𪰠𨑲𫱵𫡤𘁴𪁥𘁣𫁯𨱫𘁴𫱮𪑧𪁴𛠢').replace(/uD./g,'')))


111 (just packing all the string and removing the eval around):

unescape(escape('𜐬𘀲𛀠𜰠𫰧𨱬𫱣𪰬𘀴𘁯𙱣𫁯𨱫𘁲𫱣𪰬𒠵𛀠𝠬𘀷𘁯𙱣𫁯𨱫𛀠𞀠𫰧𨱬𫱣𪰠𬡯𨱫𛀊𞐬𘀱𜀬𘀱𜐠𫰧𨱬𫱣𪰬𘀱𜠠𫰧𨱬𫱣𪰠𬡯𨱫𛀊𥱥𙱲𩐠𩱯𫡮𨐠𬡯𨱫𘁡𬡯𭑮𩀠𭁨𩐠𨱬𫱣𪰠𭁯𫡩𩱨𭀮').replace(/uD./g,''))

• anyone else see a turtle in there...? wtf Jul 21 '14 at 19:38
• hehe, yeah, the "random" Unicode characters generated by obfuscatweet sometimes lead to emoji :)
– xem
Jul 22 '14 at 6:55

# C - 145 - try me

main(i){i<11?main(i-~1+1,printf("%d, %d, %d o'clock, %d o'clock rock,\n"
,i++,i,i-~1,i-~1+1)):puts("We're gonna rock around the clock tonight.");}


# C - 172 - try me

#define l ,__LINE__+~1
#define f ;printf("%d, %d, %d o'clock, %d o'clock rock,\n"
main(){f l
l
l
l)f
l
l
l
l)f
l
l
l
l);puts("We're gonna rock around the clock tonight.");}

• I'm not much of a C programmer, so forgive me if I am being naive, but don't you need #include <stdio.h> to use printf? Jul 17 '14 at 18:55
• default libraries are linked to the source in vc++ and gcc (so if you don't need something special, you can freely start a golfing challenge by typing main(){...
– bebe
Jul 17 '14 at 19:00
• Ah, I see. That's strange that it spits out a warning if it's accepted by default (just checked with my gcc & icc, no vc++ to test). Jul 17 '14 at 19:05
• it also spits sequence point warning so...-w :)
– bebe
Jul 17 '14 at 19:13
• @Kyle include files defines how external functions work (return type and parameters). Nothing to do with linking libraries. A standard C compiler will passs whatever parameters you like to any function (with warnings) and return values are often ignored, so it works anyway. Jul 17 '14 at 20:21

# PHP - 125 129

Version 1 (129)

$i;while($i<11)echo++$i.", ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";echo"We're gonna rock around the clock tonight";


Version 2 (125)

while($i++<11)echo"$i, ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";echo"We're gonna rock around the clock tonight";  Clean version: while($i++<11)
echo "$i, ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";
echo "We're gonna rock around the clock tonight";


# Perl, 114111110 108

$s=", X o'clock";$_="X, X$s$s rock,
"x(1+1+1)."We're gonna rock around the clock tonight.";s/X/++$i/eg;print  110: $s=", X o'clock";print(("X, X$s$s rock,
"x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/egr)  111: print(("X, X, X o'clock, X o'clock rock, "x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/egr)


114:

($s="X, X, X o'clock, X o'clock rock, "x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/ge;print$s  ## C++ 261 203 #include<iostream> #define x i++; #define y std::cout<< #define z y x y void m(){for(int i=1;i<11;){z", ";z", ";z" o'clock, ";z" o'clock rock, "<<"\n";}y"We're gonna rock around the clock tonight.";}  Edited my first attempt; it worked when I first tested it, but that seems to be a fluke; post-increment in a stream is "undefined behaviour", and it did weird things (including blue screening Windows 7!) when I tried re-running it. I think that using printf instead of std::cout could be used with post-increment to get a shorter program. Edited again, got it down to 231 by re-implementing the loop. Edited yet again, now down to 203...those #defines weren't all useful in the looping version. For those wondering how C++ can run a function "m", the entry point can be defined as any function with just a compiler option, as can setting all funcs to be stdcall; I used both switches when compiling the above. If you don't like the redefined entry point, add 3 to my character count. • Which compiler are you using? gcc (4.7.1) doesn't allow me to call the main function m(). You can however drop the void and save 5 characters (or 2 if you name the method main) Jul 17 '14 at 17:18 • how on earth did it get any upvotes? firstly you wrote a function called 'm' that will not compile by default, secondly every compiler shows the hours in reverse order. this needs a BIG correction – bebe Jul 17 '14 at 18:59 • @HackerCow I can't seem to make VS2013 work without the void return type defined; is there a compiler switch that would allow that? Jul 17 '14 at 23:57 • @bebe I explain the m() entry point in my edit; as for the output hours being printed in reverse order, I never managed to duplicate that, but I did manage to get it to print correctly (the first time I tried it), then on retesting all 1's, 5's and 12's, then on another retest it crashed the OS. So, technically it ran once, but relying on undefined behaviour is probably a 'bad idea', so I rewrote it :) Jul 18 '14 at 0:00 • @bebe I'm cool either way; in no way am I going to "win" any code golf puzzle with C++, so adding 3 characters is no biggie. I agree that -D switch macro definitions would be cheating, but pretty much any other compiler flags seem legit to me, as they also seemed legit to folks in the thread you linked. Any advantage you squeeze out of simple compiler switches won't exactly even the playing field between C++ and Python/Bash/Perl etc. Jul 18 '14 at 2:55 # Swift - 136 134 var x=1 for;x<11;{print("\(x++), \(x++), \(x++) o'clock, \(x++) o'clock rock,\n")} print("We're gonna rock around the clock tonight.")  ## Java, 228 A hardcoded solution would have probably been shorter. public static void main(String[] a){ String s = ""; int i=1,j=1; for(i--,j--;i<=11;){ s += ++i + (j > 1 ? " o'clock rock, ":", "); if(j == "one".length()){ j -= j; s +="\n"; }else j++; } System.out.println(s+"We're gonna rock around the clock tonight"); }  • +1 for the realization that hard-coding would be shorter. Jul 18 '14 at 13:52 • 1+1+1 is 9 characters shorter than "two".length()". And is String[] a necessary? Jul 18 '14 at 13:53 • That kinda felt like cheating, and yes, String[] a is necessary. Jul 18 '14 at 14:07 • It's not cheating, several people have used it :D Jul 18 '14 at 14:09 ## Befunge-98 (402 268) Now a unefunge! ".thginot kcolc eht dnuora kcor annog er'eW"a11+/a*1-> #;:,1+" ,",,:,1+" ,",,:,1+" ,kcolc'o "a1-k,:,1+a",kcor kcolc'o "ek,:a11+/a*b1111+++-+-#;_:,a-1+" ,",,:a111++-:*,,1+" ,",,:a111++-:*,,1+" ,kcolc'o "a1-k,:a111++-:*,,1+a",kcor kcolc'o "ek,:a11+/a*b1111+++-+$aa*k,@

• Random bits of backward text, ,,:,1+, a11+/a*b1111+++-+w:,, stray characters underneath the main line of code... typical Befunge. Most of the online interpreters are having problems with the line length (it's way over the limit), do you know of one that doesn't mind?
– user16402
Jul 17 '14 at 18:24
• I couldn't find any Befunge-98 compilers online, but you could use pyfunge which is available in PyPI. Jul 17 '14 at 19:51

## Groovy - 140 139 chars

Golfed, influenced by William Barbosa's answer:

s="ock"
i=1
f={->println "${i++},${i++}, ${i++} o'cl$s, ${i++} o'cl$s r$s,"} f();f();f() println "We're gonna r$s around the cl$s tonight"  Ungolfed: s = "ock" i = 1 f = { -> println "${i++}, ${i++},${i++} o'cl$s,${i++} o'cl$s r$s,"}
}

f();f();f()

println "We're gonna r$s around the clock tonight"  # Mathematica - 153 i=1; StringReplace[ StringJoin[ Riffle[{s="X, X, X o'clock, X o'clock rock,",s,s},"\n"]]<> "\nWe're gonna rock around the clock tonight.","X":>ToString[i++]]  • +1, I think this is the best strategy but it can be shorter. – user11030 Jul 19 '14 at 1:59 ## C++ 252 #define P(x) cout<<x #define Q cout<<", " #define N cout<<endl #define C P(" o'clock") #define R P(" rock") #define F P(++i);Q;P(++i);Q;P(++i);C;Q;P(++i);C;R;N; int i; main() { F F F P("We're gonna rock around the clock tonight."); }  • Unless my math sucks, using P(", ") in place of Q saves you 2 characters. Jul 17 '14 at 19:46 • N and R only appear once: it would be better to inline them than to make a macro. – user16488 Jul 18 '14 at 1:31 • Using the above comments and more this can be condensed to 200 (even with the include and namespaces my compiler wants): #include<iostream> #define P std::cout<<++i<< #define C" o'clock" #define F P", ";P", ";P C<<", ";P C<<" rock"<<std::endl; int i;main(){F F F std::cout<<"We're gonna rock around the clock tonight.";}  Jul 23 '14 at 14:10 # Cobra - 193 class P var i=1-1 def main print[.f,.f,.f,"We're gonna rock around the clock tonight."].join("") def f as String return"[[.i+=1,.i+=1,.i+=1].join(", ")] o'clock, [.i+=1] o'clock rock,\n"  ## Java (v2) - 250241 232 chars This is a complete running program, influenced by William Barbosa's answer. Golfed: public class R{ static int o=1; static String c(){return o+++", "+o+++", "+o+++" o'clock, "+o+++" o'clock rock,\n";} public static void main (String[] a){System.out.println(c()+c()+c()+"We're gonna rock around the clock tonight");}}  Ungolfed: public class R { static int o = 1; static String c() { return o+++", "+o+++", "+o+++" o'clock, "+o+++" o'clock rock,\n"; } public static void main (String[] a) { System.out.println(c()+c()+c()+"We're gonna rock around the clock tonight"); } }  # ECMAScript6 - 136 135 Doesn't even use the allowed 1 digit: alert([,...a=[s=", ",s,(c=" o'clock")+s,c+" rock,\n"],...a,...a].map((x,i)=>i+x).join("")+"We're gonna rock around the clock tonight.")  Tested in Firefox console. • or 114 chars using xem.github.io/obfuscatweet ;) – xem Jul 18 '14 at 16:21 • @xem, I know it fits in with the letter of the law, but I'm not a fan of Unicode compression (or any other compilers/generators). In my mind, golf is a test of skill and all code should be hand crafted... but that's just me. Jul 18 '14 at 22:43 # Golflua -125 Basically a direct translation of my Lua solution: k=1+1o=" o'clock"c=", "~@i=1,11,k+k I.w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")$w("We're gonna rock around the clock tonight.")


## PowerShell, 123118 109

1,1,1|%{"$('',''," o'clock"," o'clock rock"|%{"$((++$a))$_,"})"}
"We're gonna rock around the clock tonight."


After a horrible start (167) I got rid of a few idioms I didn't even need and at least got it shorter than the reference.

## Haskell -- 138 137 chars

As a standalone program:

r n=show n++s!!n
s=" o'clock rock,\n":c:c:" o'clock, ":s
c=", "
main=putStr$(r=<<)[1..11+1]++"We're gonna rock around the clock tonight."  Edit: I used to have a helper function o used to define s by s=o" rock,\n":c:c:o c:s;o=(" o'clock"++)  but it turns out to cost 1 extra character. Is there any way to compress all of the "o'clock"s / "rock"s / "ock"s? ## JavaScript, 140 a=", x o'clock",b="x, x"+a+a+" rock,\n",b+=b+=b+"We're gonna rock around the clock tonight.";for(i=1;i<=11+1;)b=b.replace("x",i++);alert(b)  I make a string like "x, x, x o'clock x o'clock rock,\n..." Then I replace the "x's" with numbers. # PHP 150 No numbers, including the 11 which would not be two 1's stuck together, but the number value eleven. function f(){static$i;echo++$i.", ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";}f();f();f();echo"We're gonna rock around the clock tonight";

• It's missing the trailing full-stop.
– Joey
Jul 19 '14 at 10:30