Write lines in detention

64

10

Introduction

Bad news guys - you got detention. Your English teacher doesn't understand this site and wants you to "stop doing math on your digital dohickeys, this is English class!"

She sentenced you to write her favorite saying on the blackboard 25 times, which will give a total of 100 lines on the blackboard.

The eighteen-hundreds were a time for rum.
The nineteen-hundreds were a time for fun.
The two-thousands are a time to run
a civilized classroom.

Lucky for you, you are an avid reader (not to mention an expert code-golfer)! You have a read about a trick that might possibly get you off easy.

foxtrot

(Foxtrot by Bill Amend)

Unfortunately for Jason, it didn't work out. But you have a better idea! Since your English teacher thinks you're doing math, if you leave all the numbers out of your program it just might work! You also want to keep your program as short as possible because you are a lazy student and don't want to write a lot on the board.

Write a program that complies with the following rules:

  • Your program must print the 4 above lines 25 times. The lines must be outputted in that order, repeating. Total exactly 100 lines of output (a trailing newline at the very end or a leading newline at the very beginning is okay).
  • You cannot use the characters 0123456789. Your teacher gets confused by math and will call you out!
  • You can use any imports and external libraries without counting the imports. Your English teacher doesn't know about programming. Jason could have saved a lot of work by not writing #include <stdio.h> and you don't want to make his same mistakes!
  • Score your program by byte count. Lowest score wins!

hmatt1

Posted 2014-10-23T13:52:20.457

Reputation: 3 356

2If the text would've read "1900s", writing the output would've been slightly more tricky. – Ingo Bürk – 2014-10-23T14:50:11.813

30to the comix: he's not printing \n's, and the loop from 1 is pretty awkward (like against C nature)... – V-X – 2014-10-23T15:41:33.923

11@V-X Bill Amend is a long-time Pascal die-hard, and whenever he writes C that becomes pretty apparent. – fluffy – 2014-10-23T18:09:48.490

Can we see some Brainfuck code here? :) – AStopher – 2014-10-23T21:23:39.833

1

@cybermonkey It's here http://codegolf.stackexchange.com/a/40256/148

– Kevin Brown – 2014-10-24T03:19:06.563

1The issue with allowing free imports is Python: from random import random as r - it can combine imports and aliases into one statement. Probably not too useful for a simple challenge like this though – None – 2014-10-24T07:16:00.907

Would you allow a leading newline? – Beta Decay – 2014-10-25T14:11:41.477

5This sounds very much like one of my old English teachers. – Kaz Wolfe – 2014-10-25T16:58:10.377

2Banning + would have made sense here, but maybe that would have been too difficult. – Pharap – 2014-10-28T09:38:41.240

Answers

9

CJam, 109 107 106 104 103 bytes

0000000: 22 0c 20 4f 18 41 e4 d8 a5 f3 95 cf 5e 2b cb 1c  ". O.A......^+..
0000010: 44 64 2f bf 28 23 e2 47 4e 4e 77 73 fc 43 09 a2  Dd/.(#.GNNws.C..
0000020: 09 0b fb 18 29 e8 e8 49 5d fc 00 da b8 70 b6 3e  ....)..I]....p.>
0000030: 0c 24 d7 5a 5b 28 1c 45 2e 90 63 86 04 5c 3e 95  .$.Z[(.E..c..\>.
0000040: 4b ae 66 22 48 48 2a 62 46 47 2b 62 22 54 0a 20  K.f"HH*bFG+b"T. 
0000050: 2d 2e 22 27 7b 2c 57 25 7c 66 3d 7b 28 2f 29 2a  -."'{,W%|f={(/)*
0000060: 7d 5a 2a 43 44 2b 2a                             }Z*CD+*

The above is a reversible xxd dump.

Testing

You can generate and execute the above code by running this in the online interpreter:

"bxyyeighxrum.yninexfun.ytwo-thousands abto run
a civilized classroom.y
The xteen-hundreds webfor bre a time ""T
 -."'{,W%|f#31bHH*b:c`'\2*/'\*"HH*bFG+b""T
 -."`"'{,W%|f={(/)*}Z*CD+*"]:+~

To see the generated code (without executing it), remove the final ~.

To count the number of bytes (one character is one byte in ISO-8859-1), replace the final ~ with a ,.

Printable version (122 bytes)

"bxyyeighxrum.yninexfun.ytwo-thousands abto run
a civilized classroom.y
The xteen-hundreds webfor bre a time "{(/)*}Z*CD+*

After pushing the string (S), the following gets executed:

{    }Z*        " Repeat 3 times:     ";
 (              "     Q := S.shift()  ";
  /             "     T := S.split(Q) ";
   )            "     R := T.pop()    ";
    *           "     S := T.join(R)  ";
        CD+*    " S *= 12 + 13        ";

Moar golfing

After pushing the unprintable string (U), the following gets executed:

HH*b                        " U := U.base(17 * 17) ";
    FG+b                    " U := U.base(15 + 16) ";
        "T\n -."            " P := 'T\n -.'        ";
                '{,W%|      " P |= 'zyx...\0'      ";
                      f=    " U[i] -> P[U[i]]      ";

This pushes the string of the printable version. The rest of the code works as before.

Dennis

Posted 2014-10-23T13:52:20.457

Reputation: 196 637

Using the code, I get this generated code which is 144 bytes. Am I doing something wrong ?

– Optimizer – 2014-10-23T22:49:20.840

UTF-8 encoding would result in a higher byte count, yes. With ISO-8859-1, the byte count is 109. You can replace ~ with , to verify. – Dennis – 2014-10-23T22:53:34.460

Not sure about ISO-8859-1 , but simply replace ~ with , just gives character count, no ? – Optimizer – 2014-10-23T22:58:05.060

Correct, but all character codes are less than 256, so one character is one ISO-8859-1 byte. – Dennis – 2014-10-23T23:00:28.017

I dunno about this. I see a ½ in there... ;) – FryAmTheEggman – 2014-10-24T00:14:26.283

2I got the exact result Optimizer did, but adding the ]:+~ made it work. Why don't you just add that to your code? – Luminous – 2014-10-24T03:12:22.903

Does CJam support ISO-8859-1? – jimmy23013 – 2014-10-24T10:58:03.670

1@user23013: The Java interpreter respects $LANG for I/O. Internally, CJam just has 16-bit chars. – Dennis – 2014-10-24T11:37:15.803

@Dennis That's great. I have an unfinished CJam program to generate ASCII-only bmp files, which is meaningless now. – jimmy23013 – 2014-10-24T12:36:57.333

3You actually do not have to unicode-ize your solution as without compression itself it is only 124 bytes, beating all others. – Optimizer – 2014-10-24T21:23:49.590

76

JavaScript (ES6) 164

B='teen-hundreds were a time',alert(B.replace(/./g,
"The eigh"+B+" for rum.\nThe nine"+B+" for fun.\nThe two-thousands are a time to run\na civilized classroom.\n"))

Test In FireFox/FireBug console.

edc65

Posted 2014-10-23T13:52:20.457

Reputation: 31 086

http://pastebin.com/YMSYGYzu < 151 bytes. Try here: http://www.es6fiddle.net/if2va393/ – Ismael Miguel – 2015-09-27T18:56:09.087

Oops, left a few bytes behind: http://pastebin.com/djn6Yhy6 < 146 bytes (tweetable). Try on: http://www.es6fiddle.net/if2vm7qm/ (for any ES5 browser).

– Ismael Miguel – 2015-09-27T19:06:42.397

1@IsmaelMiguel I think you mean any ES6 browser. Problem: at time this challenge was posted, template strings were not implemented in any browser: Firefox was the first - rel 34, dec first 2014 - then Chrome, march 2015. But even without template strings your scoure would be 153, better than mine. You should post it as an answer. – edc65 – 2015-09-27T20:03:40.550

@IsmaelMiguel if you decide to post it, you have my vote (I always vote answer better than mine) – edc65 – 2015-09-27T20:05:54.380

@edc65 No no, that link works in any browser. I tested it on IE11. It's an online transplier. – Ismael Miguel – 2015-09-27T20:36:17.180

1@IsmaelMiguel uh, ok, nice. Something to remember, thank you – edc65 – 2015-09-27T20:41:13.940

@edc65 Nice work, I hadn't considered using str1.replace(/./g, str2) as a loop... I'll have to consider this for future golfs... – WallyWest – 2016-09-08T00:04:44.533

19This is genius! – Optimizer – 2014-10-23T17:09:51.547

@Optimizer I don't know JavaScript well, but is this taking the string B and replacing its entirety with the larger string a number of times equal to B's length? – FryAmTheEggman – 2014-10-23T17:48:14.887

1Yup, replacing each character by the larger string. Making 25 copies of the larger string. – Optimizer – 2014-10-23T17:49:17.587

1@Optimizer That is genius :) – FryAmTheEggman – 2014-10-23T17:49:52.280

I can't help thinking the OP was expecting it. The oddly phrased repeated section just happened to be 25 characters long. – Malvolio – 2014-10-24T10:49:07.707

3@Malvolio In fact the repeated section is 30 characters. And I could show a huge sequence of attempts, adding and cutting words and replacing replaces before finding this simple solution. – edc65 – 2014-10-24T12:13:47.023

Why specifically are we using alert? Is there some rule that the JS console output is undesirable? – ShadowCat7 – 2014-10-24T19:16:12.180

@ShadowCat7 implicit console output is cheating in my opinion. console.log is longer. – edc65 – 2014-10-24T20:18:11.407

Such cleverness in a simple challenge like this. PPCG never stops amazing me. – Ingo Bürk – 2014-10-25T09:36:51.167

Brilliant. Great work! – Hydrothermal – 2014-10-28T00:45:39.000

34

Python : 188 173 160 153

a="teen-hundreds were a time"
print"The eigh%s for rum.\nThe nine%s for fun.\nThe two-thousands are a time to run\na civilized classroom.\n"%(a,a)*len(a)

I don't python much, but this seems pretty short to me.

Edit: So I was wrong, it wasn't short at all! Thanks for the assistance in comments :D

Geobits

Posted 2014-10-23T13:52:20.457

Reputation: 19 061

1You could lose the newline and indent on the for loop to save a couple of bytes. – Holloway – 2014-10-23T15:39:49.990

@Trengot Thanks, I forgot about that for some reason :) – Geobits – 2014-10-23T15:41:45.370

I'm fairly sure you could save a fair few in the string as well. Give me a moment. – Holloway – 2014-10-23T15:45:18.323

@Trengot I tried it as a single line and got a runtime error ('a' not defined). For an extra byte I can split it in two lines, though. Thanks! – Geobits – 2014-10-23T15:56:08.500

If you move the last five characters out of a, it will be 25 characters long. Then your for loop can be for i in a: – Rob Watts – 2014-10-23T16:03:14.993

@RobWatts He could also do for i in a[3:]. – FryAmTheEggman – 2014-10-23T16:04:28.357

@FryAmTheEggman 3 is not allowed – Rob Watts – 2014-10-23T16:04:56.277

@RobWatts Ach, you're right :). I think this is better: len(b[ord('x'):]). – FryAmTheEggman – 2014-10-23T16:09:05.647

@FryAmTheEggman, still too long. Stop a after time, then for i in a:print b – Holloway – 2014-10-23T16:10:27.530

1@Geobits, I make that 157 – Holloway – 2014-10-23T16:11:19.170

@Trengot What's 157? The code I have posted is 160. I've counted it several times now... Is what you're counting different somehow? – Geobits – 2014-10-23T16:19:06.227

1@Geobits are you running on a windows machine? The line encodings in windows are frequently \r\n instead of just \n. That might be why it's showing 157 bytes for us, but 160 for you. – Rob Watts – 2014-10-23T17:49:01.643

2

This is 160 only. You are probably skipping the three \ in \n due to escaping ...

– Optimizer – 2014-10-23T17:51:11.837

@RobWatts I thought of that, so counted each line separately (29,111,18), plus a byte for each of 2 newlines makes 160. I really can't see any other way to count it. – Geobits – 2014-10-23T17:52:10.000

1You can move the value for b into the print: % has higher precedence than *. – FryAmTheEggman – 2014-10-23T19:22:13.827

You can lose the space too :) print'' is perfectly valid. – FryAmTheEggman – 2014-10-23T19:24:39.093

@FryAmTheEggman Cool, I wasn't sure the string/math precedence would work right there. – Geobits – 2014-10-23T19:25:26.083

@Geobits Actually, I think I was mistaken: they have the same precedence, the % just comes first. (So it's still fine) – FryAmTheEggman – 2014-10-23T19:32:20.747

@Luminous I took those 5 out so that len(a) is 25. If I add them back, it doesn't save because I have to get 25 some other way. – Geobits – 2014-10-27T12:51:35.943

29

CJam, 151 140 135 132 130 128 bytes (Tweetable)

"TeighYrum.TnineYfun.Ttwo-thousands are a time to run
a civilized classroom.""YT"["teen-hundreds were a time for ""
The "]erAF+*

Try it here

I am able to shorten this down to 110 bytes by converting this to unicode, but since that is not beating the other unicode solution, I would rather not put it :)

Optimizer

Posted 2014-10-23T13:52:20.457

Reputation: 25 836

23Hey, what's that :D emoticon doing there?! Are you texting your friends during detention? Go to the principal's office! – Doorknob – 2014-10-23T21:11:28.747

2@Doorknob :D :P – Optimizer – 2014-10-23T21:16:14.410

Maybe you could make T alias to .\nThe, then remove the extra line that this produces from the start of the output string (my cjam-fu isn't good enough to figure out whether you can easily do that) – None – 2014-10-24T07:21:56.027

Nitpicking: Using the upper 128 bytes of an ASCII-compatible code page has nothing to do with Unicode. – Dennis – 2014-10-25T16:39:47.600

23

PHP, 0 bytes



You can use any imports and external libraries without counting the imports.

To run this code, you must import a library called data://text/plain,<?php...classroom.\n"; with this:

<?php require_once 'data://text/plain,<?php
  for($i=ord("z");$i>ord("a");$i--)
    echo "The eighteen-hundreds were a time for rum.
The nineteen-hundreds were a time for fun.
The two-thousands are a time to run
a civilized classroom.
";'; ?>

And you must have allow_url_include enabled in your php.ini.

No more numbers or extensions, thanks to Dennis.

jimmy23013

Posted 2014-10-23T13:52:20.457

Reputation: 34 042

9My first instinct was to yell something about loopholes, but since this answer is actually self-contained, I think this is a clever way of using PHP to exploit a loophole that has been created deliberately for Python answers. Since you're already cheating, you could just use require_once "data://text/plain,The eighteen-hundreds...";, which doesn't require sh, doesn't use numbers and is still 0 bytes. – Dennis – 2014-10-24T16:36:29.037

10I'll upvote this for creativity but I won't accept this one. – hmatt1 – 2014-10-25T16:52:43.987

14

Ruby, 185 180 176 bytes

EDIT: String interpolation, thanks @britishtea

It's my first golf ever, and I'm not much of a Rubist (but I certainly love Ruby). Anyway, this is it (shortened, Doorknob's suggestion).

t=' were a time for '
s="The eighteen-hundreds#{t}rum.
The nineteen-hundreds#{t}fun.
The two-thousands are a time to run
a civilized classroom."
s.split.size.next.times{puts s}

jmm

Posted 2014-10-23T13:52:20.457

Reputation: 241

1You can golf this down further by replacing some of the repeating words / word-groups with String interpolation. – britishtea – 2014-10-23T16:35:37.793

3+1 for noticing there are (almost) 25 words in the string – Digital Trauma – 2014-10-23T21:52:27.497

2s.split.size.next saves 5 characters (you don't need to specify the space to split on). – Doorknob – 2014-10-23T23:50:17.443

I don't know Ruby, but wouldn't (s.split.size+1).times be 1 byte shorter? – seequ – 2014-10-25T20:54:45.417

1@Sieg not allowed to use numbers! – rjdown – 2014-10-26T02:31:52.100

@rjdown Somehow I forgot. – seequ – 2014-10-26T13:00:41.307

13

Java 249 231 230 222

My first answer! Why not start off using the language I know so well.

class c{public static void main(String[]g){for(int a='!';a++<':';out.println("The eighxrum.\nThe ninexfun.\nThe two-thousands are a time to run\na civilized classroom.".replaceAll("x","teen-hundreds were a time for ")));}}

Ungolfed

import static java.lang.System.*;
class c
{
    public static void main(String[]g)
    {
        for(int a='!';a++<':';out.println("The eighxrum.\nThe ninexfun.\nThe two-thousands are a time to run\na civilized classroom.".replaceAll("x","teen-hundreds were a time for ")));
    }
}

Luminous

Posted 2014-10-23T13:52:20.457

Reputation: 309

9

Welcome! You can get rid of the public for your class and shorten args to a single character. You could also do a++<':' instead of incrementing it separately. Since the OP isn't counting imports, you can save a bit more with import static java.lang.System.*;, then you don't need to write System. later (where it counts). Doing that I got it down to around 230. You might want to take a look at the Java tips page if you haven't already.

– Geobits – 2014-10-23T15:35:18.257

@Optimizer Thanks! I just didn't see the strikeout above. – Luminous – 2014-10-23T15:58:38.903

@Luminous NP :) – Optimizer – 2014-10-23T16:01:52.260

@Geobits Thank you! Apparently, you can also stick code right into the loop itself. Didn't add or remove anything, but I think it looks more golfed that way. – Luminous – 2014-10-23T16:02:05.333

4Loop abuse is pretty common. If you had multiple statements in the body, you could put one on the outside and the rest inside to save a single character (since you need a semicolon outside anyway). A lot of golfs end up being one big loop that way. Also, "looks more golfed" is a totally valid reason to do anything even if it doesn't save :P – Geobits – 2014-10-23T16:05:09.493

@Geobits Interesting. I'll remember that. Also between you, me, and anyone reading these comments, I wonder where the C# answer got his inspiration from? – Luminous – 2014-10-23T16:11:14.100

Not really. There's usually only a few short ways to do it, so there's bound to be overlap. Compare yours to the older C version, for example.

– Geobits – 2014-10-23T16:22:27.840

11

C 171

a='a';b="teen-hundreds were a time for ";main(){for(;a++<'z';)printf("The eigh%srum.\nThe nine%sfun.\nThe two-thousands are a time to run\na civilized classroom.\n",b,b);}

At first, I tried the simplistic version (189 bytes), which was better than the other C solution...

main(a){for(a='a';a<'z';++a)printf("The eighteen-hundreds were a time for rum.\nThe nineteen-hundreds were a time for fun.\nThe two-thousands are a time to run\na civilized classroom.\n");}

which I later optimized a bit...

V-X

Posted 2014-10-23T13:52:20.457

Reputation: 747

1Huh, that's nifty. I didn't realise static variables with string literals assigned to them implicitly have type char *. – FireFly – 2014-10-23T19:38:46.653

@FireFly GCC compiles fine on the a presumably because it defaults to int, which can accept a char value. It doesn't like b unless I call it a char[] though. V-X, what compiler are you using? – Level River St – 2014-10-23T20:17:19.887

b is int too but it holds the pointer to the string literal. It's completely ok in GCC (I have on my machine 4.8.2). – V-X – 2014-10-24T06:51:32.577

1for(a='a';++a<'z';) – seequ – 2014-10-25T20:59:13.013

9

JavaScript, ES6, 174 172 154 bytes

Using @edc65's replace trick. Thanks!

alert((d="teen-hundreds were a time").replace(/./g,`The eigh${d} for rum.
The nine${d} for fun.
two-thousands are a time to run
a civilized classroom.
`))

Works only in latest Firefox (34 and above) due to use of template strings.

Optimizer

Posted 2014-10-23T13:52:20.457

Reputation: 25 836

@Nijikokun You know that will cause 30 repetitions instead of 25, right ? – Optimizer – 2014-10-24T20:45:17.787

I am guessing that ff 34 is beta or something since I am on latest (just checked) and it is 33 and it does not work on there – Sammaye – 2014-10-28T16:12:30.847

8

BrainFuck (1,597 characters)

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

This can still be golfed further, if anyone is interested.

You can test this out and confirm that it gives the correct output while meeting all of the rules.

Kevin Brown

Posted 2014-10-23T13:52:20.457

Reputation: 5 756

5What's this? I told you to write sentences, not random squiggles! There aren't even any words in here! – Riking – 2014-10-25T21:27:27.457

5Ummm.. I think the goal is to use the fewest characters. You sure won the "anti-goal" :-) – Carl Witthoft – 2014-10-27T12:01:51.327

7

Perl - 145

I'm happy to see so many answers! Here's a Perl solution.

$s="teen-hundreds were a time for";print"The eigh$s rum.
The nine$s fun.
The two-thousands are a time to run
a civilized classroom.
"for b..z

hmatt1

Posted 2014-10-23T13:52:20.457

Reputation: 3 356

7

Since she hates math so much, why not Mathematica (177)

   a = "teen-hundreds were a time for "; Do["The eigh" <> a <> "rum.
   The nine" <> a <> "fun.
   The two-thousands are a time to run a civilized classroom." // Print, {StringLength@a}]

Ryan Polley

Posted 2014-10-23T13:52:20.457

Reputation: 189

6

Javascript ES6, 198 193 bytes

m=Math;alert("The eighteen-hundreds were a time for rum.\nThe nineteen-hundreds were a time for fun.\nThe two-thousands are a time to run\na civilized classroom.\n".repeat(~~(m.exp(m.PI)+m.E)))

Your teacher doesn't want any numbers, but since they are an english teacher, they've got no clue what Math.floor(Math.exp(Math.PI)+Math.E) means.

More readably:

alert("The eighteen-hundreds were a time for rum.\n\
 The nineteen-hundreds were a time for fun.\n\
 The two-thousands are a time to run\na civilized\n classroom.".repeat(Math.floor(Math.exp(Math.PI)+Math.E)))

Must be run in the latest firefox

scrblnrd3

Posted 2014-10-23T13:52:20.457

Reputation: 1 554

1Missing a newline at end, so the first and last rows are appended giving 75 rows – edc65 – 2014-10-23T16:00:16.197

I'll award +1 for bending the rules with XKCD's reference of e^pi, but with +e as opposed to -pi... Bravo! – WallyWest – 2014-10-24T04:25:55.253

-4 bytes: with(Math)alert("long string here".repeat(exp(PI)+E|[])) – nderscore – 2014-10-24T19:59:35.393

Oh well, forget about Math: (q='aaaaa'.length)*q – edc65 – 2014-10-24T23:11:46.430

Forget about @edc65 comment too! Use this:"\x18".charCodeAt()! (hardcode the arrow up and you will save a ton!) – Ismael Miguel – 2014-10-25T20:25:59.433

6

Javascript - 178 Bytes 176 Bytes

My first golf, thought I'd give it a shot with bit twiddling operators, didn't turn out quite as well as hoped, but oh well!

c="teen-hundreds were a time for "
b=!!c
alert(Array((b+b+b<<b+b)+b<<b).join("The eigh"+c+"rum.\nThe nine"+c+"fun.\nThe two-thousands are a time to run\na civilized classroom.\n"))

Since I'm already in detention, and obviously have troubles behaving myself... Javascript - 71 Bytes

This one will probably get me in deeper trouble, but, if I already landed myself in detention, AND I'm planning on cheating my detention, apparently I lack good judgement on how I should behave myself in class. Maybe if I can pull one over my on teacher, I can pull one over on all the other golfers out there.

b=+true;alert( Array((b+b+b<<b+b)+b<<b).join($('code')[+!b].innerHTML))

Quick! Chrome/IE 11/Firebug users, open your consoles RIGHT NOW and try it.

(Please don't hurt me too much, I thought it was funny)

Sidney

Posted 2014-10-23T13:52:20.457

Reputation: 161

1The 72 is fun. The 176 is many times wrong: Array(25).join() gives 24 repetitions, and a newline at end sentence is missing. All in all 24*3=72 rows instead of 100 (lazy boy!) – edc65 – 2014-10-23T22:26:52.787

AUGH, ok fixed. Now 178 and 71. – Sidney – 2014-10-23T22:42:05.003

1You can save 2 bytes adding the t and a trailing space in "een-hundreds...for". – Luminous – 2014-10-24T03:19:56.057

What is the second code doing? – justhalf – 2014-10-24T03:58:17.333

+1 for abusing the OP's use of "code" in the second submission ;) – WallyWest – 2014-10-24T04:39:51.413

1@justhalf, It takes use of JQuery, a common JavaScript library that apparently the SO network utilizes. The $ is actually a function that, among many many other things, takes a lot of the work out of DOM element selection. By using $('<selector>'), which is in this case all elements with the 'code' tag, I get an object containing all elements. By using [+!b] I get the integer value of false, which is zero, so I select the 0th index, which happens to be the OP's first code block, which is in fact the teachers favorite saying. – Sidney – 2014-10-24T13:20:35.183

That "taking it from the question or another answer" thing is not funny anymore. It's been done plenty of times. – Ingo Bürk – 2014-10-26T17:01:43.313

5

C# - 229 216 Bytes

Free using FTW!

using c=System.Console;
class S{static void Main(){var a="teen-hundreds were a time";for(int b=a.Length,i=b-b;i++<b;)c.Write("The eigh"+a+" for rum.\nThe nine"+a+" for fun.\nThe two-thousands are a time to run\na civilized classroom.\n");}}

Alternative, same byte count (more usingabuse, though)

using i=System.Int32;
using c=System.Console;
class S{static void Main(){var a="teen-hundreds were a time";for(int b=new i();b++<a.Length;)c.Write("The eigh"+a+" for rum.\nThe nine"+a+" for fun.\nThe two-thousands are a time to run\na civilized classroom.\n");}}

William Barbosa

Posted 2014-10-23T13:52:20.457

Reputation: 3 269

4~~ (╯°□°)╯︵ ┻━┻ – William Barbosa – 2014-10-23T18:46:11.650

You can add " for " to a – FryAmTheEggman – 2014-10-23T19:01:28.623

@FryAmTheEggman the string is 25 characters long, he is using it to obtain the number 25 discretely. However, he can swap this method out for simply subtracting chars from each other (':'-'!' == 25), which is shorter than a.Length, and will allow for to be included as you suggest. (Alternativly, do as other answers seem to, and just loop between ! and :, funny how we all chose the same chars) – VisualMelon – 2014-10-23T19:47:11.390

@VisualMelon Whoops, you're totally right. – FryAmTheEggman – 2014-10-23T19:57:45.273

Int32... that sounds like math to me! So your second code is not allowed... – Sanchises – 2014-10-26T09:11:27.250

1I thought I could since usings are not even being counted, has OP clarified this? – William Barbosa – 2014-10-26T14:35:41.497

I guess you can say the second solution is abUsing... – rodolphito – 2014-10-28T06:07:27.497

Using the overload for Console.Write(format, args) instead of declaring a saves you even more "+a+" x2 (10b) >>> {0} x2 & , (7b), var a= & ; (7b) removed completely. Combined with suggestion from @VisualMelon should allow you to break 200. – Michael – 2014-10-29T16:58:40.550

{0} contains a number – William Barbosa – 2014-10-29T19:45:01.643

Aye, makes sense that I never post here. :) – Michael – 2014-10-29T20:10:49.383

5

Befunge-93, 268 260 256 (grid size: 72x6=432)

#v"K">:!#@_v>$"enin">,,,,::-" rof emit a erew sderdnuh neet">:#,_$::!!-#
, ,,,"The "<|\!\%-"\^"::%-" #":-!!:
   -"#-"-::$_ "hgie"^v1"two-thousands are a time to run"
$_$  "nuf"v"rum"
v1-"##",,,<      >:#,_"moorssalc dezilivic a"1
_# < ^,,\-"AK."$_,#!:

This is my first time golfing, so I figured I'd try a language that hadn't already been done for this problem, since I wouldn't be adding anything otherwise. Since it's Befunge-93 compatible (fits inside an 80x25 grid and uses only Befunge-93 instructions), it should work in Befunge-98 too. Just in case, I also avoided having the pointer pass over any non-instruction characters other than space. I couldn't remember whether the specification actually defined those characters as no-ops, and I'll be having no nasal demons in MY code.

You can't really ungolf Befunge code. The key thing to note here is that Befunge pushes characters to the stack as their ASCII values, making it relatively simple to refer to numbers without literally referring to them. The "K" in the top left is 75, referring to the number of repetitions times the number of "the" clauses per repetition; I use modulus and some other craftiness on (copies of) this number to determine which path to take through the printing on each go-around. ::- is a nice idiom for zero, useful for zero-terminating strings; I use it twice here.

On occasion the pointer needs to pass through a place where I'm defining a string, hence the specific choices of characters used to get certain numbers at some points.

The nice thing about a lot of Befunge interpreters is that you can watch the pointer dart around the grid, as well as see what values are in the stack. That way you can step through and see how the program works yourself, more or less! I'd recommend using http://befungius.aurlien.net/ if you don't have your own preferred Befunge interpreter.

This can probably be pared down a bit (or a lot) more. Please give me feedback! If I need to provide a better explanation, someone let me know; I'm new to this.

Edit - shaved off a few bytes by getting rid of the unnecessary redirect to the last row when the program terminates (just putting the @ where the ^ used to be).

Another edit - shaved off some more bytes in various places, mostly with trickery. (Also added the grid size, as seems to be the trend with Befunge answers.)

Kasran

Posted 2014-10-23T13:52:20.457

Reputation: 681

I'm not using any Funge-98-specific instructions or behaviors that I know of, but since I wrote this answer I did learn that certain behaviors of the Befungius interpreter aren't standard - namely using # at one end of a line to skip the character at the other end (in CCBI, for instance, the # just skips the infinite space in between it and the character at the other end), which breaks this program. I haven't bothered to come back and fix this submission with this in mind.

– Kasran – 2017-01-17T18:42:27.630

There's a few 1 digits in there, which are not allowed – Jo King – 2019-04-14T13:36:02.103

Hey Kasran welcome to the codegolf stack exchange! This answers look great. Your explanation is good and you linked to a Befunge interpreter which is really helpful for weird languages not everyone has a compiler for (people commonly do things like "run this here"). – hmatt1 – 2014-10-25T16:04:17.877

Befunge is a really hard language, and you have to keep the size of the code itself in your mind when writting. Your code looks great and works. But would it reduce the size if you save re a time somewhere? – Ismael Miguel – 2014-10-25T16:26:24.987

4

Pyth 135 136 140

*ltG%"The eigh%srum%snine%sfun%stwo-thousands are a time to run\na civilized classroom.\n"*hhZ("teen-hundreds were a time for "".\nThe 

Note the trailing space.

Uses pretty much the same trick as @Geobits and his commenter friends in the Python answer to construct the string. Now also uses some of this answer.

This uses the built-in variable G, which contains abcdefghijklmnopqrstuvwxyz and gets one less than its length to produce the 25 outputs.

FryAmTheEggman

Posted 2014-10-23T13:52:20.457

Reputation: 16 206

1

This seems to be 136 bytes rather than 135

– Optimizer – 2014-10-23T17:05:07.343

1@Optimizer Sorry, I should read my own notes: I forgot the trailing space when I pasted it there myself :S – FryAmTheEggman – 2014-10-23T17:18:26.840

4

Ruby - 152 141

puts"The eight#{e="een-hundreds were a time for "}rum.
The ninet#{e}fun.
The two-thousands are a time to run
a civilized classroom.
"*(?X-??)

http://repl.it/2Om/6

Mikey

Posted 2014-10-23T13:52:20.457

Reputation: 141

1Clever use of 1.8's character literals! You might be able to use String#* to repeat the lines 25 times instead of Integer#times. – britishtea – 2014-10-23T23:12:44.457

@britishtea - worked a treat :) – Mikey – 2014-10-23T23:18:34.517

1You could shave off a few more bytes by not assigning the lines first. The space between puts and a string literal is optional (puts"hi" is legal). – britishtea – 2014-10-23T23:20:56.903

Assigning e inside the interpolation is a nice touch. – Wayne Conrad – 2014-10-24T12:26:15.623

3

LiveScript - 181

p=(a,b)->"The #{a}teen-hundreds were a time for #b.\n"
each console.log,map (->(p \eigh \rum)+(p \nine \fun)+'The two-thousands are a time to run\na civilized classroom.'),[\A to\Y]

Required imports:

{each, map} = require 'prelude-ls'

If you want to run it under Node.js, install the LiveScript (not livescript) and prelude-ls packages from npm, replace alert with console.log and run lsc prog.ls, where prog.ls contains the program.

nyuszika7h

Posted 2014-10-23T13:52:20.457

Reputation: 1 624

13See rules: "You cannot use the characters 0123456789" – Paul R – 2014-10-23T16:22:25.190

2Nice catch, fixed. – nyuszika7h – 2014-10-24T10:48:22.627

3

PHP (175 157 156 bytes; 152 with unix EOF):

Not the most golfed solution, but surely does the job and is smaller than some attempts.

Here is the code:

$a=a;$f='re a time';$r="teen-hundreds we$f for";while($a++<z)echo"The eigh$r rum.
The nine$r fun.
The two-thousands a$f to run
a civilized classroom.
";

Old version:

$a=a;while($a++!=z)echo"The eighteen-hundreds were a time for rum.
The nineteen-hundreds were a time for fun.
The two-thousands are a time to run
a civilized classroom.
";

This works because php cycles the chars, and we just check if it isn't z and stop.

(One curiosity is that when php reaches z, it then goes to aa.)

Ismael Miguel

Posted 2014-10-23T13:52:20.457

Reputation: 6 797

3The general convention here is to count newlines as only one byte, unless perhaps your language is so stubborn it only accepts CRLF, which is not the case for PHP. – nyuszika7h – 2014-10-25T08:54:43.290

3

Python 2 - 155

Note: since control characters don't show on SE, I've replaced it with \x19.

a,b='\nThe ','teen-hundreds were a time for '
print(a+'eigh'+b+'rum.'+a+'nine'+b+'fun.'+a+'two-thousands are a time to run\na civilized classroom.')*ord('\x19')

Base 64 version:

YSxiPScKVGhlICcsJ3RlZW4taHVuZHJlZHMgd2VyZSBhIHRpbWUgZm9yICcKcHJpbnQoYSsnZWln
aCcrYisncnVtLicrYSsnbmluZScrYisnZnVuLicrYSsndHdvLXRob3VzYW5kcyBhcmUgYSB0aW1l
IHRvIHJ1bgphIGNpdmlsaXplZCBjbGFzc3Jvb20uJykqb3JkKCcZJyk=

Beta Decay

Posted 2014-10-23T13:52:20.457

Reputation: 21 478

Regarding the import, I think you could save a bit with from string import * or however it's called in Python – FireFly – 2014-10-23T17:25:59.917

1You can move "teen" into b. – FryAmTheEggman – 2014-10-23T18:48:40.240

2You can remove the [] brackets in the first line, which implicitly creates a tuple and then unpacks it. – Doorknob – 2014-10-23T23:51:53.527

You can also move the ord('d')//len('aaaa') to before the string so you don't have to bracket it. – FryAmTheEggman – 2014-10-24T00:20:55.777

Your output is missing the dots. I'm not sure if the leading newline is allowed. – Dennis – 2014-10-25T14:06:25.757

1@Dennis The OP's latest edit allows leading newlines. – Beta Decay – 2014-10-25T14:25:48.927

3

Python, 165 bytes

h="hundreds were a time for "
t="The "
for i in h:print t+"eighteen-"+h+"rum.\n"+t+"nineteen-"+h+"fun.\n"+t+"two-thousands are a time to run\na civilized classroom."

It worked out really nicely that the length of h is 25, that was not intentional. =)

James

Posted 2014-10-23T13:52:20.457

Reputation: 54 537

3

Python 2 - 143

A silly answer:

from this import i
a="teen-hundreds were a time for ",".\nThe "
print"The eigh%srum%snine%sfun%stwo-thousands are a time to run\na civilized classroom.\n"%(a+a)*i

Note that the full count is 162. I left out all of from this import i.

Uses similar replacements to my pyth strategy, but I couldn't resist posting this after discovering the hilariousness of importing from this :)

FryAmTheEggman

Posted 2014-10-23T13:52:20.457

Reputation: 16 206

+1 For use of from this import i! How did you know about that? – Beta Decay – 2014-10-26T16:54:56.187

1@BetaDecay I actually was bored and decided to read the zen of python, so I went to my interpreter and wrote import this. Then I thought: "What else could be in the this module?" So I called dir(this). Lo and behold, along with a dictionary, a garbled up string, and a "!" variable, there was a numeric constant... equal to 25. – FryAmTheEggman – 2014-10-26T23:35:21.970

2

EXCEL, 168 Bytes

Decided to add this for fun. Instead of using the length() I decided to use character codes... If SUBSTITUTE wasn't such a long command, I could have joined in on the string compression too. I am drooling over C# which can use: 'Z'%'A'

Similar to the other Excel, but not using any row / column references.

Decided to add this for fun. Instead of using the length() I decided to use character codes... If SUBSTITUTE wasn't such a long function I could have joined in on the string compression too.

Similar to the other Excel, but not using any row / column references.

=REPT("The eighteen-hundreds were a time for rum. 
The nineteen-hundreds were a time for fun. 
The two-thousands are a time to
run a civilized classroom. ",ARABIC("XXV"))

Origin

Posted 2014-10-23T13:52:20.457

Reputation: 121

excluding new line, I counted it 179. XD. let's wait for the others what should be the correct count byte. Also you can less some bytes if you use subtraction instead of Mod. Also, need to add new line at the end of the sentence – remoel – 2019-04-16T08:52:50.543

2ARABIC("XXV") is even shorter than CODE("Z")-CODE("A"). – orthoplex – 2019-04-16T09:06:59.970

@remoel - Yes I considered the subtraction, but I liked that there was nothing "Mathy" looking (+ or -) in the formulas. orthoplex - nice, that also meets my other criteria! – Origin – 2019-04-16T09:11:31.803

Line endings are almost universally counted without carriage return on here. TIO would be correct in that case. – orthoplex – 2019-04-16T09:23:04.213

@Origin 1. run is on the wrong line. 2. you no longer use char codes so you need to update the explanation – ASCII-only – 2019-04-16T12:06:50.657

@orthoplex, never knew that function. lol. Thank you! – remoel – 2019-04-17T01:22:44.873

2

05AB1E, 91 bytes

AgG“TheŸ¯een-““«Ã€à€…€º€‡ “©“ê¶m.“««“The¥Šteen-“®„ˆ¦.««“The‚•-““šä€™€…€º€„‡Ð“«“a–Ìized¬¸.“»

Try it online!

Emigna

Posted 2014-10-23T13:52:20.457

Reputation: 50 798

83 bytes – Kevin Cruijssen – 2019-06-04T10:28:57.253

2

C, 215 203 199 bytes

main(a){a<<='\xC'+'\xD';while(a>>=!!a)printf("The eighteen-hundreds were a time for rum.\nThe nineteen-hundreds were a time for fun.\nThe two-thousands are a time to run\na civilized classroom.\n");}

Ungolfed

main(a)
{
  a<<='\xC'+'\xD';
  while(a>>=!!a)
    printf("The eighteen-hundreds were a time for rum.\nThe nineteen-hundreds were a time for fun.\nThe two-thousands are a time to run\na civilized classroom.\n");
}

I used bit shifting to iterate without any number.

a<<='\xC'+'\xD' sets a to 0b1[25 zeros]

a>>=!!a shifts right one bit for each time we iterate the loop

Edit : a equals argc, so its value is already 1 when the program is run with no arguments. Changed a>>='\xB'-'\xA' to a>>=!!'\xA' which is 4 bytes shorter. Also the text was displayed only 24 times. Fixed it. Removed extra brackets in the while.

Edit 2: changed !!'\xA' to !!a. Seems to work and saves 4 bytes

Ethiraric

Posted 2014-10-23T13:52:20.457

Reputation: 161

1You can use puts to save more bytes. – Spikatrix – 2015-06-02T09:58:16.787

2

Ruby, 145

?K.upto(?c){puts"The eigh#{x="teen-hundreds we#{t="re a time "}for "}rum.
The nine#{x}fun.
The two-thousands a#{t}to run
a civilized classroom."}

Explanation

  • Use String#upto to print the lines 25 times. The range "K".."c" is 25 characters.
  • Use basic String interpolation to shorten the lines.

britishtea

Posted 2014-10-23T13:52:20.457

Reputation: 1 189

2#{a="The "} is actually costing you more characters! #{a} is the same length as The – Mikey – 2014-10-23T23:34:16.407

2

T-SQL: 206

Makes use of a cross join on five rows to generate 25 rows selecting the phrase. The line breaks are important for the output.

with c as(SELECT\ N FROM(VALUES(\),($),($),($),($))A(B))SELECT REPLACE('The eigh$rum.
The nine$fun.
The two-thousands are a time to run
a civilized classroom.','$','teen-hundreds were a time for ')FROM c a,c b

MickyT

Posted 2014-10-23T13:52:20.457

Reputation: 11 735

2

Bash, 151 bytes

Pretty much a straight port of your own answer

t="teen-hundreds were a time for"
for i in {a..y};{
echo "The eigh$t rum.
The nine$t fun.
The two-thousands are a time to run
a civilized classroom."
}

Digital Trauma

Posted 2014-10-23T13:52:20.457

Reputation: 64 644

2

Perl - 152 146 bytes

$_="-hundreds were a time for";say"The eighteen$_ rum.\nThe nineteen$_ fun.\nThe two-thousands are a time to run\na civilized classroom.\n"x y///c

This makes use of perl's string repetition operator and exploits a substring of length 25.

Ungolfed version:

$_ = "-hundreds were a time for";
say "The eighteen$_ rum.\nThe nineteen$_ fun.\nThe two-thousands are a time to run\na civilized classroom.\n"x y///c

Gowtham

Posted 2014-10-23T13:52:20.457

Reputation: 571

1Use $_ instead of $h and then you can use length or better yet y///c without the $h argument. You can put a space between the x and length and get rid of the parenthesis. Think perl -E'$_="test";say"t"x y///c' – hmatt1 – 2014-10-23T20:43:54.210

@chilemagic Thanks, that saved 5 bytes and removing trailing semicolon saved one more. – Gowtham – 2014-10-31T18:13:47.740

2

C, 196 chars

This isn't an easy task for good ol' C. Factoring out the "The %steen-hundreds ..." pattern saves me a whole two characters.

Whitespace for clarity, include not counted.

#include <stdio.h>
main(){
  for (char*p="The %steen-hundreds were a time for %s.\n",
           *s="The two-thousands are a time to run\na civilized classroom.",
           *q=p;
       *q++ - 'a';
       puts(s))
   printf(p,"eigh","rum"), printf(p,"nine","fun");
}

FireFly

Posted 2014-10-23T13:52:20.457

Reputation: 7 107

2

Golfscript - 139 134

'TeighYrum.TnineYfun.Ttwo-thousands aRto run
a civilized classroom.''#
'{-}**'Y'/'teen-hundreds weRfor '*'T'/'
The '*'R'/'re a time '*

Teacher: Joshy * , are you hashtagging in class again? Two weeks detention! #howdoesthatfeel

* name preserved to protect idensity

EDIT: Found shorter code.

Josiah Winslow

Posted 2014-10-23T13:52:20.457

Reputation: 725

2

Racket 173

(let([x"teen-hundreds were a time for "])(for([z(+ #xa #xf)])(displayln(~a"The eigh"x"rum.\nThe nine"x"fun.\nThe two-thousands are a time to run\na civilized classroom."))))

Ungolfed:

(let ([x "teen-hundreds were a time for "])
  (for([z(+ #xa #xf)])
    (displayln (~a "The eigh"x"rum.\nThe nine"x"fun.\nThe two-thousands are a
     time to run\na civilized classroom."))))

Matthew Butterick

Posted 2014-10-23T13:52:20.457

Reputation: 401

2

PHP - 157

$f='re a time';$r="teen-hundreds we$f for";echo str_repeat("The eigh$r rum.\nThe nine$r fun.\nThe two-thousands a$f to run\na civilized classroom.\n",aa^SU);

Mad Angle

Posted 2014-10-23T13:52:20.457

Reputation: 121

5Use $s instead of $string to save on quite a few bytes. – Zaenille – 2014-10-24T11:41:30.553

1If you want to use str_repeat, use this: $f='re a time';$r="teen-hundreds we$f for";echo str_repeat("The eigh$r rum.\nThe nine$r fun.\nThe two-thousands a$f to run\na civilized classroom.\n",aa^SU); (hardcode the \n to save bytes.) and you have a 153 byte long answer! (aa^SU is 24, which is the same as (a^S)*10+(a^U) which is (2*10)+4) I based the divisions on my code. Please, present a bytecount next time and try to golf it further. – Ismael Miguel – 2014-10-25T19:12:33.750

Please update the byte count when you update the answer. You can use https://mothereff.in/byte-counter, make sure there's no empty line at the end. Also, this can be golfed futher by removing the spaces around the = and the newline after classroom.";.

– nyuszika7h – 2014-10-28T12:06:14.247

2

GML (Game Maker Language), 169

a="teen-hundreds were a time for "b="The eigh"+a+"rum#The nine"+a+'fun#The two-thousands are a time to run#a civilized classroom#"c=b+b+b+b+b;d=c+c+c+c+c;show_message(d)

Timtech

Posted 2014-10-23T13:52:20.457

Reputation: 12 038

2

Common Lisp (165 bytes)

(format t"~v{~{The ~(~A~)~#[~;-thousands are~:;teen-hundreds were~] a time ~A
~}~:*~}"(+ #xA #xF)'((eigh"for rum."nine"for fun."two"to run
a civilized classroom.")))

Explanations

  • 25 equals to 10 + 15, which is equivalent to A + F in base 16. Hence (+ #xA #xF).
  • 25 is passed to the ~v{ ... ~} constructs, which iterates over arguments at most v times, where v is given as an argument of format
  • ~:* rewinds current argument to the previous element in the argument list; inside the ~{...~} constructs, that practically means infinite loop. However, this infinite loop is bounded by ~v, ie. 25.
  • ~#[<zero>~;<one>~;:<else>~] is a switch, based on the value of the remaining number of arguments in the list (due to the # modifier).
  • ~(...~) downcases the contained text

Note: I could have used fewer characters by using ~R on 18, 19 and 2 (and using a litteral 25) but this is forbidden.

coredump

Posted 2014-10-23T13:52:20.457

Reputation: 6 292

2

Rant, 191 bytes

Not the shortest solution, but still cool. I wrote a subroutine to write the first three lines, and designed it so calling it with an empty argument returned a string 25 characters long. I then pass its length to the repeater.

[pin:][$[_:a]:The [arg:a][sync:;ordered]{thousands a|teen-hundreds we}re a time ][r:[len:[$_:]]]{[step:][$_:eigh]for rum.\N[$_:nine]for fun.\N[step:][$_:two-]to run\Na civilized classroom.\N}

Ungolfed:

[pin:]
[$[_:a]:The [arg:a][sync:;ordered]{thousands a|teen-hundreds we}re a time ]
[r:[len:[$_:]]]
{
    [step:]
    [$_:eigh]for rum.\N
    [$_:nine]for fun.\N
    [step:]
    [$_:two-]to run\N
    a civilized classroom.\N
}

Try it online

Berkin

Posted 2014-10-23T13:52:20.457

Reputation: 61

2

LATEX 239 226

The byte count does not include the \documentclass command nor any \usepackage commands. I would argue both count as using external packages, as the former includes definitions in an external .cls file, and usepackage is practically synonymous with an include statement. Output is a pdf file containing the 100 lines with no other text, formatted appropriately. Try it at writelatex.com!

\begin{document}\newcounter=\def\_{re a time }\def\-{een-hundreds we\_}\StrLen\-[\b]\forloop=\parindent{\value=<\b}{The eight\-for rum.\\The ninet\-for fun.\\The two-thousands a\_to run\\a civilized classroom.\\}\end{document}

Ungolfed:

\documentclass{letter}

\usepackage{forloop}
\usepackage{parskip}
\usepackage{xstring}
\usepackage{nopageno}

\begin{document}

\newcounter=

\def\_{re a time }
\def\-{een-hundreds we\_}

\StrLen\-[\b]

\forloop=\parindent{\value=<\b}{

    The eight\-for rum.\\
    The ninet\-for fun.\\
    The two-thousands a\_to run\\
    a civilized classroom.\\

}

\end{document}

Edit: New and improved. Also made link go to read-only version of code. Thank you Dennis!

wwarriner

Posted 2014-10-23T13:52:20.457

Reputation: 131

1

>

  • You should link to the read-only version of your document. I accidentally modified it (but undid all changes). 2. You can save a few bytes by eliminating whitespace and curly brackets : \begin{document}\newcounter=\def\_{re a time }\def\-{een-hundreds we\_}\StrLen\-[\b]\forloop=\parindent{\value=<\b}{The eight\-for rum.\\The ninet\-for fun.\\The two-thousands a\_to run\\a civilized classroom.\\}\end{document}
  • – Dennis – 2014-10-26T14:18:41.180

    Suggested changes made, thank you for the tips. – wwarriner – 2014-10-26T16:34:42.767

    You're over-optimizing it. It would be much shorter if you did it like my plainTeX solution. :P – nyuszika7h – 2014-10-27T13:53:49.240

    Interesting, thanks. Rather than modify my answer, I'm going to upvote yours! Cheers! – wwarriner – 2014-10-27T15:55:23.783

    Looks like mine is currently invalid though, I overlooked the #1s. :/ – nyuszika7h – 2014-10-27T16:29:06.153

    I had the same problem with my original MATLAB entry, and missed it in yours as well. Typing and seeing numbers while coding is a subtle thing, evidently. Definitely adds to my humility that I am not fully aware of precisely what I am doing at all times! – wwarriner – 2014-10-27T16:55:25.400

    2

    Perl, 140 139

    improving on chilemagic answer. feature say for 3 bytes, text redundancy for 3 bytes.

    $r="re a time";$s="teen-hundreds we$r for";say"The eigh$s rum.
    The nine$s fun.
    The two-thousands a$r to run
    a civilized classroom."for b..z
    

    Matija Nalis

    Posted 2014-10-23T13:52:20.457

    Reputation: 121

    You can move the r into $e as well to save another byte. – hmatt1 – 2014-10-24T22:08:12.470

    @chilemagic duh, thanks! missed that somehow. Under 140 now! – Matija Nalis – 2014-10-24T22:44:12.457

    2

    TeX - 169

    \def\s{teen-hundreds were a time for }\def\p{The eigh\s rum.
    
    nine\s fun.
    
    The two-thousands are a time to run
    
    a civilized classroom.
    
    }\def\m{\p\p\p\p\p}\m\m\m\m\m\bye
    

    Note that the blank lines are intentional and actually required for the output to be properly formatted.

    nyuszika7h

    Posted 2014-10-23T13:52:20.457

    Reputation: 1 624

    1It's fixed now. :) – nyuszika7h – 2014-10-27T18:12:13.863

    1

    Forth (gforth), 174 bytes

    : x ." teen-hundreds were a time for ";
    : f bl true cell+ do ." The eigh"x .\" rum.\nThe nine"x .\" fun.\nThe two-thousands are a time to run\na civilized classroom.\n"loop ;
    

    Try it online!

    Code Explanation

    : x                                      \ start a new word definition
      ." teen-hundreds were a time for "     \ outputs "teen-hundreds were a time for "
    ;                                        \ end word definition
    
    : f                                      \ start a new word definition
      bl                                     \ ascii value of space (32)
      true cell+                             \ true (-1) + size of cell (8 in 64-bit) = 7
      do                                     \ counted loop from 7 to 31 (total of 25)
        ." The eigh"x                        \ output "The eigh" and call x
        .\" rum.\nThe nine"x                 \ output "rum\nThe nine" and call x              
        .\" fun.\nThe two-thousands are a time to run\na civilized classroom.\n" \ output the rest
      loop                                   \ end loop
    ;                                        \ end word definition
    

    reffu

    Posted 2014-10-23T13:52:20.457

    Reputation: 1 361

    1

    Perl 6, 147 bytes

    my $t="teen-hundreds were a time for";say "The eigh$t rum.
    The nine$t fun.
    The two-thousands are a time to run
    a civilized classroom." for 'a'..'y'
    

    Try it online!

    bb94

    Posted 2014-10-23T13:52:20.457

    Reputation: 1 831

    'a'..'y' -> ^㉕ :P since it looks like unicode numbers are fine – ASCII-only – 2019-04-16T12:19:23.830

    1140? – ASCII-only – 2019-04-16T12:24:35.810

    1

    EXCEL , 160 164 bytes

    asked Teacher if I could use Excel, Teacher said Yes.

    asked Teacher if I could click around, Teacher said Yes.

    So click Wrap Text, merge A-TwentyFive to A-OneHundredTwentyFive and Paste this in Cell A-TwentyFive

    =REPT("The eighteen-hundreds were a time for rum.
    The nineteen-hundreds were a time for fun.
    The two-thousands are a time to run
    a civilized classroom.
    ",ROW())
    

    remoel

    Posted 2014-10-23T13:52:20.457

    Reputation: 511

    I count this as 164, did I miss something? – Origin – 2019-04-16T08:18:59.060

    I'm using TIO to count the bytes of my code. are you referring to the New Line? maybe its not counting it. will add it. Thank you :) – remoel – 2019-04-16T08:41:11.143

    1

    Brainfuck, 659 bytes

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

    Try it online!

    I found this using my own mediocre Brainfuck cruncher.

    orthoplex

    Posted 2014-10-23T13:52:20.457

    Reputation: 339

    1

    Java 247 229 225

    Not counting package and import statements

    class A{public static void main(String[] a){String s="teen-hundreds were a time for "; for(int i='a';i++<'z';)out.print("The eigh"+s+"rum.\nThe nine"+s+"fun.\nThe two-thousands are a time to run\na civilized classroom.\n");}}
    

    Ungolfed

        package a;
        import static java.lang.System.*;
        class A{
            public static void main(String[] a){
                String s="teen-hundreds were a time for "; 
                for(int i='a';i++<'z';)
                out.print("The eigh"+s+"rum.\nThe nine"+s+"fun.\nThe two-thousands are a time to run\na civilized classroom.\n");
            }
        }
    

    Guido

    Posted 2014-10-23T13:52:20.457

    Reputation: 11

    1

    C# (193)(189)

    (Executable in LINQPad)

    Golfed:

    void Main(){for(int i='!';i++<':';)"The eighteen-hundreds were a time for rum.\nThe nineteen-hundreds were a time for fun.\nThe two-thousands are a time to run\na civilized classroom.".Dump();}
    

    Ungolfed:

    void Main()
    {
        for(int i='!';i++<':';)
            "The eighteen-hundreds were a time for rum.\nThe nineteen-hundreds were a time for fun.\nThe two-thousands are a time to run\na civilized classroom.".Dump();
    }
    

    After update:

    void Main(){var x="teen-hundreds were a time for ";for(int i='!';i++<':';)"The eigh_rum.\nThe nine_fun.\nThe two-thousands are a time to run\na civilized classroom.".Replace("_",x).Dump();}
    

    Ungolfed:

    void Main()
    {
        var x="teen-hundreds were a time for ";
    
        for(int i='!';i++<':';)
            "The eigh_rum.\nThe nine_fun.\nThe two-thousands are a time to run\na civilized classroom.".Replace("_",x).Dump();}
    

    Abbas

    Posted 2014-10-23T13:52:20.457

    Reputation: 349

    1

    Haskell (210 192 chars)

    My code is fairly simple:

    import Data.Char
    i x y="The "++x++"teen-hundreds were a time for "++y++".\n"
    main=putStr.unlines.replicate(ord '\EM')$(i"eigh""rum"++i"nine""fun"++"The two-thousands are a time to run\na civilized classroom.")
    

    Joins a 25x replicated list of the desired string and prints it. (\EM is ASCII 25)

    Edit

    Updated score to omit import and trailing newline from count.

    archaephyrryx

    Posted 2014-10-23T13:52:20.457

    Reputation: 1 035

    1

    MATLAB 175 193

    R2014a

    Fun with fprintf. I hope I didn't miscount, first timer here.

    a = 'a time ';b = 'teen-hundreds were %sfor';for i = length([]):length(b);fprintf(['The eigh',b,' rum.\nThe nine',b,' fun.\nThe two-thousands are %sto run\na civilized classroom.\n'],a,a,a);end
    

    Ungolfed

    a = 'a time ';
    b = 'teen-hundreds were %sfor';
    for i = length([]):length(b);
        fprintf(
            [
                'The eigh',
                b,
                ' rum.\nThe nine',
                b,
                ' fun.\nThe two-thousands are %sto run\na civilized classroom.\n'
            ],
            a,
            a,
            a
        );
    end
    

    Note that fprintf prints to MATLAB's console by default, unless a valid file identifier is supplied as the first argument. The character sequence %1$s instructs fprintf to print the first argument after the format string as a string. In this case, the variable b needs to be 25 characters long, so using %s instead of %1$s actually costs a couple more characters overall, once all strings have been manipulated.

    Edit: fixed to conform to rules. Lesson learned: don't post early morning.

    wwarriner

    Posted 2014-10-23T13:52:20.457

    Reputation: 131

    Fixed to conform to rules. How embarrassing! – wwarriner – 2014-10-24T18:54:49.087

    1

    Delphi (229 227 224/238)

    Not great but still fun.
    Repeats for each char in set ['B'..'Z'].

    This is a procedure so use clauses aren't included. You will need the unit IdGlobal for this to work. Including the unit it will be 238.

    procedure W;var C:Char;begin for C in['B'..'Z']do writeln(StringsReplace('%eigh^+for rum.*%nine^+for fun.*%two-thousands are+to run*a civilized classroom.',['%','^','*','+'],['The ','teen-hundreds were',^J,' a time ']));end;
    

    Ungolfed

    procedure W;
    var C:Char;
    begin
      for C in['B'..'Z']do
        writeln(StringsReplace('%eigh^+for rum.*%nine^+for fun.*%two-thousands are+to run*a civilized classroom.',['%','^','*','+'],['The ','teen-hundreds were',^J,' a time ']));
    end;
    

    Replace broken up

    StringsReplace(
    '%eigh^+for rum.*%nine^+for fun.*%two-thousands are+to run*a civilized classroom.', //source string
    ['%','^','*','+'], //Patterns to replace
    ['The ','teen-hundreds were',^J,' a time '])//Replace pattern with.
    

    Teun Pronk

    Posted 2014-10-23T13:52:20.457

    Reputation: 2 599

    See rules: "You cannot use the characters 0123456789" – Paul R – 2014-10-24T11:02:35.167

    @PaulR Oops, forgot the newline contained numbers -.-; Changed it, saved me 2 characters aswell :P – Teun Pronk – 2014-10-24T11:09:29.367

    Better, but I still see 0 and 1 in there... – Paul R – 2014-10-24T11:18:52.127

    Oh wow... can't believe I missed that xD – Teun Pronk – 2014-10-24T12:10:56.780

    1

    Java: 252 bytes

    class M{public static void main(String a[]){String t="teen-hundreds were a";for(int i='!'-'!';i<'z'-'a';i++){System.out.println("The eigh"+t+" time for rum.\nThe nine"+t+" time for fun.\nThe two-thousands are a time to run\na civilized classroom.");}}}
    

    ungolfed:

        class M {
        public static void main(String a[]) {
            String t = "teen-hundreds were a";
            for (int i = '!' - '!'; i < 'z' - 'a'; i++) {
                System.out
                        .println("The eigh"
                                + t
                                + " time for rum.\nThe nine"
                                + t
                                + " time for fun.\nThe two-thousands are a time to run\na civilized classroom.");
            }
        }
    }
    

    Aaron C

    Posted 2014-10-23T13:52:20.457

    Reputation: 131

    1>

  • This doesn't compile (you're missing a } or have an extra {, take your pick). 2) This has been done already in the same language using the same method with 35+ less bytes, so doesn't add anything. 3) It doesn't compile. Note: I didn't downvote this, but I can see why someone would. Also note that voting is intended to be anonymous, and there's no requirement (even morally, IMO) to explain a downvote.
  • < – Geobits – 2014-10-24T15:50:29.763

    1

    Rebol - 162 160

    b: a:"teen-hundreds were a time"forall b[print reword{The eigh$X for rum.
    The nine$X for fun.
    The two-thousands are a time to run
    a civilized classroom.}[X a]]
    

    draegtun

    Posted 2014-10-23T13:52:20.457

    Reputation: 1 592

    1

    Shell, 161

    sed 's/x/xxxxx/g;s/x/The eigh#rum.\nThe nine#fun.\nThe two-thousands are a time to run\na civilized classroom.\n/g;s/#/teen-hundreds were a time for /g'<<<xxxxx
    

    Petr Pudlák

    Posted 2014-10-23T13:52:20.457

    Reputation: 4 272

    1

    Haskell - 183

    a#b="The "++a++"teen-hundreds were a time for "++b++".";
    main=forM_['A'..'Y'](\_->forM["eigh"#"rum","nine"#"fun","The two-thousands are a time to run\na civilized classroom"]putStrLn)
    

    Required imports:

    import Control.Monad
    import Data.Char
    import Data.List
    

    nyuszika7h

    Posted 2014-10-23T13:52:20.457

    Reputation: 1 624

    1

    Groovy - 149

    Golfed:

    x="teen-hundreds were a time";print"""The eigh$x for rum.
    The nine$x for fun.
    The two-thousands are a time to run
    a civilized classroom.
    """*x.size()  
    

    Little Child

    Posted 2014-10-23T13:52:20.457

    Reputation: 293

    1

    Cobra - 194

    class P
        def main
            print ('[n="\nThe "]eigh'+(p='teen-hundereds we[m="re a time "]for ')+'rum.[n]nine[p]fun.[n]two-thousands a[m]to run\na civilized classroom.\n').repeat(c'S'to int-c':'to int)
    

    Οurous

    Posted 2014-10-23T13:52:20.457

    Reputation: 7 916

    1

    PowerShell

    Count = 203 199

    $c,$d,$e,$f,$g,$h,$i,$j=("The,eigh, for ,rum.,nine,fun., to run, a time"-split",");$a="teen-hundreds were$j";[char[]]$a|%{"$c $d$a$e$f`n$c $g$a$e$h`n$c two-thousands are$j$i`na civilized classroom."}
    

    Explanation

    # Chop up this string of repeated words/phrases
    $c,$d,$e,$f,$g,$h,$i,$j=("The,eigh, for ,rum.,nine,fun., to run, a time"-split",");
    
    # Steal everyone else's idea to get 25 chars exactly
    $a="teen-hundreds were$j";
    
    # Cast to char array and pipe into foreach
    [char[]]$a|%{...}
    
    # Spell everything out
    "$c $d$a$e$f`n$c $g$a$e$h`n$c two-thousands are$j$i`na civilized classroom."
    

    SomeShinyObject

    Posted 2014-10-23T13:52:20.457

    Reputation: 953

    181 Bytes – Veskah – 2019-04-15T13:07:29.357

    1

    Groovy : 167 chars

    Inspired by jmm's answer.

    a="teen-hundreds were a time for"
    b="two-thousands are a time "
    s="The eigh$a rum.\nThe nine$a fun.\nThe ${b}to run\na civilized classroom."
    b.size().times{println s}
    

    Michael Easter

    Posted 2014-10-23T13:52:20.457

    Reputation: 585

    1

    Scala - 159

    val(f,h)=('z'-'a',"teen-hundreds were a time for")
    print(s"""The eigh$h rum.
    The nine$h fun.
    The two-thousands are a time to run
    a civilized classroom.
    """*f)
    

    triggerNZ

    Posted 2014-10-23T13:52:20.457

    Reputation: 251

    Run with scala golf.scala – triggerNZ – 2014-10-28T05:20:16.280

    1

    C99: 211

    Doubt I'll be winning any prizes any time soon:

    main(){char*s="The %steen-hundreds were %s for %s.\n",*t="a time",c='A';for(;c<'Z';++c){printf(s,"eigh",t,"rum");printf(s,"nine",t,"fun");printf("The two-thousands are %s to run\na civilized classroom.\n", t);}}
    

    Pharap

    Posted 2014-10-23T13:52:20.457

    Reputation: 195

    Golf it more by removing #include <stdio.h> and using main(){...} instead of void main(){...}. Also, char *s="..." can be written as char*s="..." to save one byte. Declaring c outside the loop an also save some more bytes:char*s="...",c; – Spikatrix – 2015-06-03T05:47:27.440

    @CoolGuy All done, and I went one better by stripping the first part of the for out and assigning c at the point it is declared. I considered switching the for to a while, but it would be a byte longer. e.g. while(c<'Z'){++c;} (18) vs for(;c<'Z';++c){} (17) – Pharap – 2015-06-03T15:17:28.047

    1

    Ruby, 198 bytes

    a='teen-hundreds were a time'
    b='The eigh'
    c='The nine'
    d=' for'
    e=' rum'
    f=' fun'
    a.length.times{puts b+a+d+e+"\n"+c+a+d+f+"\n The two-thousands were a time to run a \n civilized classroom"}
    

    Bl4ckC4t

    Posted 2014-10-23T13:52:20.457

    Reputation: 11

    1

    T-SQL - 177

    Using the string from the other T-SQL answer here.

    PRINT(REPLICATE(REPLACE('The eigh$rum.
    The nine$fun.
    The two-thousands are a time to run
    a civilized classroom.','$','teen-hundreds were a time for '),ASCII('K')/LEN('AAA')))
    

    Okay, this should properly follow the rules this time, silly me. I had almost completely forgotten about the super convenient REPLICATE function. ASCII('K') gives us 75, dividing that by LEN('AAA') which is 3 gives us the 25 we need. I could've used the character with the ASCII value 25, but having a control character seems like a bit of a cop out to me.

    PenutReaper

    Posted 2014-10-23T13:52:20.457

    Reputation: 281