# Output code-sized Lorem Ipsum

Output the same length of Lorem ipsum your code is!

Rules:

• Code can't be identical to output
• No compression libraries
• Shortest program in two weeks wins
• No network usage, file reading and other tricks which with one could easily solve any code golf problem (with eval, exec, etc)

Example

Your code with length 25.


Output

Lorem ipsum dolor sit ame

• I don't think the lorem ipsum placeholder text is standardized. What if our program is longer than the provided example? Should it simply repeat from the beginning again? – Mr. Llama Feb 25 '13 at 21:02
• @GigaWatt I provided an 1000+ character long text as link. If that's not enough then repeat. – randomra Feb 25 '13 at 21:14
• Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer nunc augue, feugiat non, egestas ut, rutrum eu, purus. Vestibulum condimentum commodo pede. Nam in metus eu justo commodo posuere. Nunc varius dui id nulla. Fusce porttitor pretium leo. Quisque in diam. Nulla pellentesque. Donec vitae urna et arcu lobortis varius. Aenean velit eros, varius ac, semper sit amet, lacinia eget, sem. Phasellus mollis nunc a pede cursus fermentum. Proin et odio. Nullam turpis. Fusce eget arcu. Mauris placerat ultricies lectus. Nullam pede nisl, ullamcorper ullamcorper, hendrerit sit amet, molestie – DavidC Feb 25 '13 at 21:17
• If we're not allowed to use network/language built-ins/compression, how are we supposed to generate information that's at least as long as the program? That's almost like pulling info out of thin air. – Mr. Llama Feb 25 '13 at 21:40
• @GigaWatt compression (assuming it doesn't have to be dynamic in length) – copy Feb 25 '13 at 21:43

## GolfScript (122 or 138 bytes)

There seems to be a very small ambiguity in the rules: what precisely does "output" mean? Many programs assume that the "output" of a program doesn't include a final newline, which is there to ensure that the next line of the shell input begins on a separate line.

00000000  27 80 38 6e df 07 55 f7  a7 8f c0 42 9d dc 1e e7  |'.8n..U....B....|
00000010  7d 48 9a 88 79 03 92 c1  fb ed 8a af 51 92 52 24  |}H..y.......Q.R$| 00000020 2c b7 0b 17 d4 eb dc b0 d8 ce 8c 82 0f 94 0d 18 |,...............| 00000030 42 71 58 8a dd e6 b9 70 9b 48 74 f5 f0 70 c2 bb |BqX....p.Ht..p..| 00000040 e0 5b 1d e1 f2 a7 29 3e 87 b4 f0 4d 3a 22 5c 71 |.[....)>...M:"\q| 00000050 55 3d d1 fd 77 12 e2 52 73 24 89 00 9b c3 e5 47 |U=..w..Rs$.....G|
00000060  0c b4 17 1a 27 32 35 36  62 61 73 65 20 39 30 62  |....'256base 90b|
00000070  61 73 65 7b 33 32 2b 7d  25 2b                    |ase{32+}%+|
0000007a


is 122 bytes and outputs 122 bytes of lorum ipsum and a trailing newline.

00000000  27 75 24 b6 ac 4e 36 10  aa 62 7f 2b 35 67 cc ee  |'u$..N6..b.+5g..| 00000010 c2 fa d4 9a 7a 54 96 e9 f0 0b 38 58 63 79 97 f8 |....zT....8Xcy..| 00000020 d5 7e 8a bc 4e e6 9b ee 88 ed f0 87 b5 9e 78 8c |.~..N.........x.| 00000030 ff 4e ac 59 49 d5 71 f1 94 51 f5 4e 6a 58 57 24 |.N.YI.q..Q.NjXW$|
00000040  f6 4a 07 40 d6 06 bb a3  34 55 8d 83 aa ce d4 41  |.J.@....4U.....A|
00000050  46 04 26 c7 ef e2 f7 00  a2 61 a9 d2 40 8c 00 d9  |F.&......a..@...|
00000060  78 9a a7 53 d6 ea 85 16  23 fd c6 2c 8d a6 cb 09  |x..S....#..,....|
00000070  0a 27 32 35 36 62 61 73  65 20 39 30 62 61 73 65  |.'256base 90base|
00000080  7b 33 32 2b 7d 25 2b 3a  6e 3b                    |{32+}%+:n;|
0000008a


is 138 bytes and produces 138 bytes of lorum ipsum with no trailing newline.

• Or.. you could count the newline as part of the output, and print 1 less byte of lorem ipsum – aditsu quit because SE is EVIL Mar 1 '13 at 18:58
• @aditsu, I considered that possibility too and reckoned it was fairly unambiguous that it would count as cheating. – Peter Taylor Mar 1 '13 at 19:35

# rot13 (1)

i'm surprised nobody came up with this before :)

Y


and as a bonus, a very simple perl solution

# Perl (252)

s//LoremIpsumDolorSitAmet,ConsectetuerAdipiscingElit,SedDiamNonummyNibhEuismodTinciduntUtLaoreetDoloreMagnaAliquamEratVolutpat. UtWisiEnimAdMinimVeniam,QuisNostrudExerciTationUllamcorperSuscipitLobortisNislUtAliquipExE/;s,([^ ])([A-Z]),$1$"\l$2,g;print  • Nice perl solution. A trivial 49 byte improvement: ...ExerciTationU/;s,\S\K[A-Z], \l$&,g;print – primo Mar 1 '13 at 9:46
• Better still for 196 bytes: print'LoremIpsumDolor...NostrudExerciT'=~s,\S\K[A-Z], \l$&,gr – primo Mar 1 '13 at 9:52 • Is rot13 a programming language? :) Also based on this idea I modify the minimum codelength to be positive... – randomra Mar 1 '13 at 19:00 • Well, code length of 1 is positive :) – aditsu quit because SE is EVIL Mar 1 '13 at 19:06 • I don't think it's a very simple perl solution any longer. – MD XF Sep 12 '17 at 3:59 # Golfscript - 161 Edit: python solution output a different length than its own, so I did a better one with golfscript. This is also my first golfscript answer. [' ,.LUabcdeghilmnopqrstuvwy''zä{~4ú›Úˆ2©JfÖØélq¤öäpDÎ;bÐô(;ÆXÔZo´dZ]e§B¥×ûba(šX†Cf½ÇUÃ0~3i‰d<Ú{¡º¯ŠÛ„å4B9W}˜$ûã–'{1-}%255base{.26%@.@=\@26/.}do;;]''+


I'm not sure how this is encoded here, so here is a link to the file.

• I'm getting 363 bytes code, 362 bytes output – aditsu quit because SE is EVIL Feb 26 '13 at 5:16
• Fixed. Also switched languages. – cardboard_box Feb 26 '13 at 15:12
• I'd ask you to post it separately, but instead I might use your ideas to improve my python solution :) – aditsu quit because SE is EVIL Feb 26 '13 at 15:38

# Python 2 - 332

print''.join([x,'tmoi eiidoqa  ua  lde  rsernponutsatmnci  '[ord(x)%21::21]]['.'<x<'D']for x in'LAe@1su@2lA6i?9et,;3sectetu/7d1Bc0gC<t,6e=di9:3ummy:ibhCuBmo=t0cidun?8 laAee?2lA>magna7<49Cr5 vol8p5. U?wBiCni@a=m0i@veni9, 4B:ostru=ex/ci t5i3 ull9cAp/6usc1i?lobAtB:Bl 87<41CxCa;ommo2;3se45. DuB78e@velCu@iriur>2lA 0 hendr/i?0 vulp85>')


If anybody cares, here's a partial list of improvements:
1181 -> 630 -> 549 -> 510 -> 456 -> 416 -> 381 -> 332

# Mathematica, 8

I make the assumption that visually identical output is acceptable. I therefore use this character in place of ASCII "i" which causes the two Symbols to be automatically sorted in the correct order:

іp*Lorem

Lorem іp


## Bash, 156

Because using a real "compression library" is forbidden, I'll abuse base64 from coreutils instead. (xxd -r to decode submission)

0000000: 7461 696c 202d 3120 2430 7c62 6173 6536  tail -1 $0|base6 0000010: 3420 2d77 307c 7472 2058 595a 205c 202c 4 -w0|tr XYZ \ , 0000020: 2e0a 6578 6974 0a2e 8ade 9978 a9b2 e997 ..exit.....x.... 0000030: 7689 68ad 7b22 b576 a67a d617 7289 ec79 v.h.{".v.z..r..y 0000040: cb5e b6e7 ab5d a762 a62b 1c8a 7817 7a58 .^...].b.+..x.zX 0000050: ad61 7b1e 7577 626a 65e7 a27b a69b 25e7 .a{.uwbje..{..%. 0000060: 89b8 577a e8ac 9a87 57b6 29dc 89db a7b5 ..Wz....W.)..... 0000070: 7bad 5e56 a8ad e7ad 5dda 25a2 b797 99a8 {.^V....].%..... 0000080: 2769 76a5 8aab 9a99 77ab 6ad5 efa2 5bad 'iv.....w.j...[. 0000090: a5ab 595d 4b57 c22b 225d e9e2 ..Y]KW.+"]..  I generated the above code using this PHP program: <?php$lorem = '<text here>';

$enclorem = base64_decode( strtr($lorem, ' ,.', 'XYZ' ) );

$prog = "tail -$3$0|base64 -w0|tr XYZ \\ ,.\nexit\n$1";

for ( $i = 0,$n = strlen( $lorem );$i < $n;$i++ ) {
$cutlorem = substr($lorem, 0, $i ); for ($j = 0, $o = strlen($enclorem ); $j <$o; $j++ ) {$cutenclorem = substr( $enclorem, 0,$j );
if ( substr( strtr( base64_encode( $cutenclorem ), 'XYZ', ' ,.' ), 0,$i )  === $cutlorem ) { break; } }$out = strtr( $prog, array( '$1' => $cutenclorem, '$2' => $i, '$3' => substr_count( $cutenclorem, "\n" ) + 1, ) ); echo "$i=i strlen($out)=" . strlen($out ) . "\n";
if ( $i === strlen($out ) ) {
break;
}
}

echo "\nHexdump:\n";
$p = popen( 'xxd', 'w' ); fwrite($p, $out ); pclose($p );

echo "\nFinal output check: ";
$tmp = tmpfile(); fwrite($tmp, $out );$md = stream_get_meta_data( $tmp ); ob_start(); passthru( 'bash ' . escapeshellarg($md['uri'] ) );
$buf = rtrim( ob_get_clean() ); echo$buf === substr( $lorem, 0, strlen($out ) ) ? 'PASS' : 'FAIL', "\n$buf\n";  • Isn't base64 some sort of compression utility? Also, I think you violate "no file reading" - you ceratainly read a file (the program itself), similarly to the "quine" cat$0. – ugoren Mar 3 '13 at 8:04

# Mathematica 47 46

Not sure if this is fair play. Mathematica has the 'full' text of Lorem ipsum in its example data. The following simply tells Mathematica to take a string of a particular length from the built-in example of Lorem Ipsum.

Edit:

e=ExampleData;e[e["Text"][[19]]]~StringTake~46


Original:

ExampleData@{"Text","LoremIpsum"}~StringTake~47


"Lorem ipsum dolor sit amet, consectetuer adipis"

## PHP, 75 (Dynamic)

<?=substr(file_get_contents('http://bit.ly/15KKxqh'),0,filesize(__FILE__));


Example output:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttito


It doesn't use compression, but it does bend the rules. A lot.
You can add garbage characters to the end of the example and still have the correct output (up to 2k+ characters).

## PHP, 59 (Static)

<?=substr(file_get_contents('http://bit.ly/15KKxqh'),0,59);


Same as above, but uses a fixed size and will be incorrect if extra characters are added.

• After the rules were amended, my answer is now invalid. – Mr. Llama Feb 27 '13 at 17:40

# Windows batch, 878 720

Tested on Windows XP and Windows 7, but should work for every cmd with extensions (IIRC, Windows NT and later).

Has to be run using CMD /V:ON /C batchfile to turn on delayed variable extension, but I prefer that to having non codegolf friendly SETLOCAL EnableDelayedExpansion inside the batch file.

@ECHO OFF
SET A=Lore2ipsu21 si0amet,6ctetu7 adip3cing4lit, sed dia2nonummy nibh4u3mod tincidun0u0laoree018magna aliqua27a0volutpat. U0w3i4ni2ad mini2veniam, qu3 nostrud4x7ci tation ullamcorp7 suscipi0lobort3 n3l u0aliquip4x4a commodo6quat. Du3 aute2vel4u2iriur81 in hendr7i0in vulputat8veli0ess8molestie6quat, vel illu21e4u feugia53 a0v7o4ros40accumsan40iusto odio dign3si2qui blandi0praesen0luptatu2zzril deleni0augu8du3 18t8feugai5i. Na2lib7 tempor cu2soluta nob34leifend option congu8nihil imp7die0doming id quod mazi2plac7a0fac7 possi2assum. Typi non haben0claritate2insitam;4s0usus legent3
FOR %%I IN ("8=e ","7=er","6= conse","5=0nulla facil3","4= e","3=is","2=m ","1=dolor","0=t ") do SET "A=!A:%%~I!"
ECHO %A%


## J (144)

Would've been 128 if I hadn't needed to make it a proper script so you can measure the output.

exit[stdout'utsrponmligfedcbaVLI., '{~#._5>\,#:a.i.'�F��$f����kg�c������$NI�f!!���L�:����l���5l�0A����Fـ���T�X ��@g�I���'


How it works: there are only 23 unique characters in the text, so this can be represented in a 5-byte encoding. The characters in the encoded string are converted to their ASCII numbers (a.i.), then each of the numbers is turned into their base-2 representation (#:), then the bits are grouped in groups of five (_5>\,), then each of these groups is converted to its value (#.), and these are used as an index into the lookup table. ({~).

The lookup table actually needed some tinkering, because a J string literal cannot contain \n, \r or \0.

Hexdump:

0000000: 7865 7469 735b 6474 756f 2774 7475 7273
0000010: 6f70 6d6e 696c 6667 6465 6263 5661 494c
0000020: 2c2e 2720 7e7b 2e23 355f 5c3e 232c 613a
0000030: 692e 272e 4691 d9c3 1024 660f 0595 841d
0000040: da90 6007 676b c214 8263 81c0 b483 921a
0000050: 4e24 9549 2166 a521 60a6 4cb1 8c1d 3a03
0000060: 02d0 ca80 6cd9 9302 d800 35c5 c56c 4130
0000070: ac80 d600 00c3 0346 80d9 88ad 8001 b454
0000080: 2058 e0a5 0f40 1467 49cd 60d8 e080 0a27

• You can compress the lookup table e.g. ('VLI., ',97}.a.)` in some way it doesn't mess up the other literal. – randomra Mar 3 '13 at 21:26