Skip to main content
1 of 2

MATLAB 175

R2014a

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

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

Ungolfed

a = 'e a time ';
b = 'teen-hundreds wer%1$sfor ';
for i = 1:length(b);
    fprintf( 
        [ 
            'The eigh',
            b,
            'rum.\nThe nine',
            b,
            'fun.\nThe two-thousands ar%1$sto run\na civilized classroom.\n'
        ],
        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.