29
\$\begingroup\$

The new site header has some bits of source code from various questions as the background. Here are the first 3 lines:

--<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+. Hello, World! IT'S SHOWTIME TALK TO THE HAND "Hello, World!" YOU HAVE BEEN TERMINATED "9!dlroW ,olleH"ck,@ 72a101a+7aa+3a44a32a87a111a+3a-6a-8a33a Take Circle Line to Paddington Take Circle Line to Wood Lane Take Circle L
alert'Hello, World!' target byteorder little;import puts;export main;section"data"{s:bits8[]"Hello, World!\0";}foreign"C"main(){foreign"C"puts("address"s);foreign"C"return(0);} aeeeaeeewueuueweeueeuewwaaaweaaewaeaawueweeeaeeewaaawueeueweeaweeeueuw H class H{public static void main(String[]a){System.
World!");}}+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+. "Hello, World!"o| :after{content:"Hello, World!" H;e;P1;@/;W;o;/l;;o;Q/r;l;d;2;P0 ('&%:9]!~}|z2Vxwv-,POqponl$Hjihf|B@@>,=<M:9&7Y#VV2TSn.Oe*c;(I&%$#"mCBA?zxxv*Pb8`qo42mZF.{Iy*@dD'<;_?!\}}|z2VxSSQ main(){puts("Hello, W

However, a few microseconds of extra load time can cause the user to click away from the site, so the page header download really should be optimized as much as possible.

Write a program that takes no input and produces the (first 3 lines of) text from the new header as output.

  • Trailing newline is optional
  • Must include the line breaks from the original header
  • , so shortest code wins!
\$\endgroup\$
  • 9
    \$\begingroup\$ I'm cautiously hopeful that the patchwork of kinds of text in the header will encourage more tailored approaches than the generic text compression methods that plague kolmogorov complexity challenges. \$\endgroup\$ – xnor Jun 15 at 1:05
  • 1
    \$\begingroup\$ @xnor Yeah, there are multiple "Hello, World"s, but then the BF and evil likely have their own interesting compression. \$\endgroup\$ – Daniel M. Jun 15 at 1:10
  • 5
    \$\begingroup\$ Just an FYI the naive bubblegum answer is 594 bytes. \$\endgroup\$ – FryAmTheEggman Jun 15 at 4:10
  • \$\begingroup\$ @FryAmTheEggman I get 588 \$\endgroup\$ – someone Jun 15 at 14:21
  • 4
    \$\begingroup\$ That System.alert is triggering \$\endgroup\$ – Benjamin Urquhart Jun 15 at 16:14
19
\$\begingroup\$

Stax, 601 584 574 564 553 539 bytes

«=¬█j▼sw│╥═7♫çÿñ╦*‼e"!‼╤Å╟D·εWÜå╖L♂@#î╚å♫▐ô;(┤┼»Kî→δäû║h◘│¶zurΘ█┐£ë}∞è┼$÷gôwg¬≤╒Ñ╧]∙ì▄╦╕ís│\☺'┴♫Φ^┐╤å{1█♠₧ï∩∙↑▀⌂d▲╡⌡3J‼¡qâ╧3¥Çƒwe▀≡╔MjZΣΩyüO╬ªÉΩö^Y╡►8K₧óN·ÿjg≈Cö9^◘■~Ä_ßx▐Å┌ Q>/♫╤QΩzN╤V½▓▀◙ß╗╗◄►(╔☺╡┘Ah╙¢√ß▼GΩ→ù◄:─◘#♫úq•ø≤>↨)Å│╤[ïmgBX┤╛v\ⁿ╛å╘╕7d╪TµbW#2¶ø╙╜~êê[↨>K►♪0∞#XJ°ñntG∞⌐V♥Z<ÿº'║☺;┤é⌡♠gáσßÑ+♂z♥‼S9 l≈╫ºÜT»↕▀τ♣¡gWe¥_çà(┬f╜n[╗╤fσ╞R₧▲V▌═◙úKÆÜ▄☺╥s1▼╩ûû╗▌▌Ω■g∞Y╡9╦tè┴y♂w∟⌂┌'╣W▀M╓·uBôúPm◘ ☻ⁿFh<╘sú▲Ö╘¶¿_2♦Θb{╪δC\lô+▀9¶ß§╡╓)ú}○8∟⌡nÑôI )╓îFbH[î║╞e&"¶↓~A#ç╔▄─áσ∙:═Æ▬ª▄ÄêQSNM◙∞Z╜≈±╘▬LIÿ|#.¿Φµ║▌Lväv▓♣;└Æ▲▄♣↕{╪½)╚φ╡♦:oÉ▀j╠ΔP<ç↔|±╦=╣▓Φ▒─4D▄■ìà>↓┐

Run and debug it

It does at least attempt to use different strategies for different pieces.
I've still got some hope for a few sections, but here's an explanation of the approaches so far.

                                    The general approach is to push a bunch of stuff on the stack. 
                                    Then join it all together and split it in thirds.
'                                   just a space
`jaH1"jS3!`X                        compressed literal for "Hello, World!" assigned to the x register
`38dZl;i#D]|@Y@*`                   compressed literal for "It's showtime talk to the hand"
^                                   convert to upper case; it compresses better in lower case
n'"|SY                              Wrap the x register in quotes and save it in the y register
`=j("sx6c1 ob`^                     compressed literal for "you have been terminated" in upper
."9                                 literal for '"9'
yrD                                 register y (quoted hello world), reversed, first character dropped
"ck,@ "                             literal
"^h{ai{W>bJ,^T+NLDK(G$s@+"!         crammed array [725, 101597559, 354, 45325875, 1115935, -65, -85335]
$"5a9+"|t                           concat as strings, then map '5' to 'a' and '9' to '+'
`='9%[mh++PxF!`                     compressed literal for " Take Circle Line to "
`~J@[E<`n                           compressed literal for "Paddington"; copy the one about the circle
`jj_kmZ5`                           compressed literal for "Wood Lane"
n7T                                 copy " Take Circle Line to " and truncate last 7 characters
"alert'"x''                         some literals and x register
`~lLKPq'III^) .tI:G8?uMolVwpnT&u#`  compressed literal with commas in place of semi-colons
.,;|t                               replace with semi-colons, which aren't allowed in compressed literals
`/zOXzN`",data,{s:bits8[],`x\0_;}`cC,main(){`cC,puts(,address,s);` C,return(0);} ".,"|t
                                    compressed literal for "foreign", followed by a string template
"Nm\{<\3VdH,FF:c~7&u!n"96|E         carefully chosen string literal interpreted in base 96
"eawu":B                            encoded in custom base "eawu"   
`dzJxVHC"`'{`pS7yzeENLM%_'`         two compressed literals with a '{' in the middle
"(String[]a){System."               literal
x6)                                 last 6 characters of register x
"`");}}"                            literal with escaped uote
"0;pKll>r&.sSP}JLNL==(>eP>-2\6fc8|)4&.:,1jA66O{t0>GpALk4I{.iDM:Gr_50ga"
90|E                                literal of ascii characters decoded in base 90
"[+-><],.":B                        re-encoded with a custom base of brainfuck
72:/                                split at position 72
~                                   push the right half to the input stack, effectively the beginning
" `yo| :after{content:`y H;e;P1;@/;W;o;/l;;o;Q/r;l;d;2;P0 ('&%:9]!~}|z2Vxwv-,POqponl$Hjihf|B@@>,=<M:9&7Y#VV2TSn.Oe*c;(I&%$#`"mCBA?zxxv*Pb8``qo42mZF.{Iy*@dD'<;_?!\}}|z2VxSSQ main(){puts("
                                    big string template including y register a few times
y9(                                 first 9 characters of y
Lr$                                 wrap all stacks in array and concatenate
3Mm                                 split into 3 equal parts and print as lines
\$\endgroup\$
  • 4
    \$\begingroup\$ Please do add a description of the strategies you employed. \$\endgroup\$ – Jonathan Allan Jun 15 at 11:18
  • \$\begingroup\$ Nice, thanks for the breakdown! \$\endgroup\$ – Jonathan Allan Jun 16 at 21:09
  • \$\begingroup\$ That yo| :after{content make it look like some kind of rap. \$\endgroup\$ – val Jun 17 at 15:20
13
\$\begingroup\$

Jelly, 568 bytes

“¢lẊḊ%ñẇÄNị¡ẸVþṾɲXØ?^ÆÐX⁷®bWċ’b7ị“-+[>].<”” “3ḅaė;œ»©“×;-¢İiĖƝÞth⁴"Ạ⁺Xṙ{»Œu®“JṁkKɼġʋḲỴ9|ḤḲ»Œu®U“ƭJ&çȯ»” Ȯø“¡ŻAÆ¡ ⁾Ʋ⁵(S0-’b122_⁵ȯ€“”ṭ"3,5,10Ṭ×”+¤j”a“Ƭ>hPḢ¤Ġ2fɠjẆȤ¬ṬwḷÇRy_ỴṬƓO¶~^YG³ẸṂḊỤÇ»®“¡ñA¦ɗɱṪḅạðEṘ/Ḋ_³ṢÑ⁺ċßs³m0>*Ḥıo7Ʋ>[;ɼ⁽¢OẆ9Ɓ€»®“¤Z!ƤḂĊlðiƝṘŻqọ6³Ṣṡḃ8Þœn⁶ʠẉ>yuẆ{»Ḳj“ṢẈ,ẊL»” ø“שK⁸ƁƬ÷FġƬṘ¹^Ẉ§ṭƁḅ’b4ị“wuae”“£¦ƊNỴŻw;ƊFɦȦnœĠÐẇṀu½X*ṠOJ8ȷḍu&)ṫ)⁼ẏµ×ẏ`ȯ»ø“¡-P⁽Rȯ$@°ḤėXƙ€ṭ⁶Vė7-²ɦ{NỌQ’b7ị“+-><].[”⁾ "®“ıȷ®⁻ʂ£Þȷ⁹ṣp°⁷»®ø“Ṛ|ġcßỵiṃ^ɱrÐẏNạŀiUĠ¥ĿSʂĊ⁷Ð+¦ŻvIṖj~ż¹kĿƥð¿ƘeḶZƤLɱ ṭṡ¥⁷ė$ ėƬ ċ⁵Ṛ¿⁷¢²_ṛż⁽p£⁽n#/i½ɱ`M3BƓḳ?¥ạuẹ09ʠ;"J!ṢIMkIoÐȯ²&_ẋẓṗḲ>½Q>ẈȯĠ ŀJṇḢC.(Eı’b128ịØJ“¡ʂh;⁼µ:ȮçṛƤb7ḋ2ṢR»

Try it online!

I tried to add optimizations per section. The optimized string compressor compresses this to 730 bytes (which should be the best possible just using basic Jelly syntactical constructs rather than any actual methods), so it appears I have done something.

(Fun fact: after I posted this answer, Chrome started suggesting translating this page to Vietnamese :P)

\$\endgroup\$
  • 2
    \$\begingroup\$ Interestingly enough, pasting your full answer into google translate detect language uses Igbo. It "translates" the part corresponding to œ»©“×;-¢İiĖƝÞth⁴"Ạ⁺Xṙ{ as "the rest", but then if I paste that substring by itself, it detects as Viatnamese and translates to gibberish. \$\endgroup\$ – Daniel M. Jun 15 at 4:26
  • \$\begingroup\$ @DanielM. Huh, that's interesting. Wonder why it recommended Vietnamese then; probably based on the Stax answer and the surrounding English. Thanks for sharing! \$\endgroup\$ – HyperNeutrino Jun 15 at 4:45
13
\$\begingroup\$

SOGL V0.12, 542 527 bytes

Hello, World!”³³"ī←≥/ī⁹βņ	fi▼pΛtι¤Υ8Th4ΚT~v‛θ5→č■⌡‘o"′]◄⅟ō&÷2}≠Θ←⁷┌∙‽↓æ³ΘZ°β╔¶ļ¹‘U┌⁷ŗo±"ē‛V)≥u∆↕]ē׀~σφ‰τ┘^|i≡»┼y3┐X3Η‛Χ4±2‘o"ΣΤ°ε⁵↑p$J↑³∫ū²▼!⁄B²⌠3τ}σS⁷bu¹1∆Ν²‘ū#Ƨtoŗo"JνΠ◄ī÷$λ⅜Zø@Pθθ╚XΔBPø√:┘¦z#│y⁹oΣ⁄½Λ'7⅞Fģ′σv+&≥μ_¦≠⅔v]lπlsβ╥^D#,℮⁾§Aα‛ķκņ▼%ķW═g!ōΜ¬`}⅛čņ█≠⁄⅔‛mZÆ~⁴πzWl─xτ▼'Η↓#ΗΩ►φL8!Ƨ:e¡′ž|Τr^+≡▒GπεΓW≥7±λxw׀ Κν⁷cP\ιYΤp|A╝æƧO∑b►\÷Q²OΟč⅔⁽(╬( ρn⁽BoG=Υ→m▒‽¤/►iΟ√PqΩ∙φ4√VΥæl‽υΧ$f0╬Dkμ⌠Lāč¾↓′∫Ε╚Βæ║↑Ν▲γB#⁶5⁹B|l↔ƨ╗6Σŗ⁄⅟ω±μξydA┼*ģ⁴Z►xa^■7O═ģΖ4Γ⅞6═¾χ‰⁷‛[‚⅓D⅞π▓z⁶‼Æņ2Υ√θ']7┐⁰īS╗<čfφ┘lθ⁄{=æ⁹Δ<¡⁾Υ□ι¹λzFΗ▲-β▒╤ÆAΩ/xff⁰ΞΠIæ┘*⁾h⁷╗ΧG─`⁾⁄@p*‘p

Try it here!

Almost all compression, but broken up every now and then because English compression works only on lowercase words and case is important. I still had to split the text up in compressible parts though.

This finally made me fix a bug in the compressor, making it unresponsive sometimes (the result still works in the previous versions though)

\$\endgroup\$
3
\$\begingroup\$

Retina, 793 bytes


--<-<<+[+[<+>--->->->-<<<]>]<<--.<6*+.<<-..<<.<+GG.<<<.+++GG-.<<<+. ^ IT'S SHOWTIME TALK TO THE HAND "^" YOU HAVE BEEN TERMINATED "9!dlroW ,olleH"ck,@ 72a101a+7aa+3a44a32a87a111a+3a-6a-8a33aXine to PaddingtonXine to Wood LaneX¶alert'^' target byteorder little;import puts;export 5;section"data"{s:bits8[]"^\0";}J5(){Jputs("address"s);Jreturn(0);} aeeeaeeewueuueweeueeuewwaaaweaaewaeaawueweeeaeeewaaawueeueweeaweeeueuw H class H{public static void 5(String[]a){System.¶World!");}}+[-->-[>>+>5*-<<]<--<---]>-G>+G..+++[.>]4*<.+++.6*-.<<-G>>+. "^"o| :after{content:"^" H;e;P1;@/;W;o;/l;;o;Q/r;l;d;2;P0 ('&%:9]!~}|z2Vxwv-,POqponl$Hjihf|B@@>,=<M:9&7Y#VV2TSn.Oe$*c;(I&%$#"mCBA?zxxv$*Pb8`qo42mZF.{Iy$*@dD'<;_?!\}}|z2VxSSQ 5(){puts("Hello, W
5
main
G
.>>
J
foreign"C"
X
 Take Circle L
\^
Hello, World!

Try it online! Well, I tried. The desired output uses all but five printable ASCII characters, but fortunately I could only find five strings with enough repetition to be worth compressing. There are also four characters repeated more than three times in a a row; these are run length encoded. Would be 1 byte longer in Retina 0.8.2 as the four run length encodings cost an extra byte each but it's then no longer necessary to quote the three desired *s.

\$\endgroup\$

Your Answer

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

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