Kolmogorov Complexity Meta Golfer Mike Bufardeci (Pyth) - 175 bytes

Leo (Retina) - 175 bytes

devRicher (Lua) - 182 bytes

Peter Taylor (CJam) - Waiting for clarification

Lyth (C++11) - Waiting for clarification



Edit: Several changes made, should not affect any already submitted answers.
Edit #2: Very few people are taking advantage of the 1024 byte limit. The point of this challenge is to output code golf answers, not things like the example at the bottom of this post.
Edit #3: Here is the paragraph to test against: WASHINGTON - These are chaotic and anxious days inside the National Security Council, the traditional center of management for a president's dealings with an uncertain world. I will test the submissions myself later.
At PPCG, we pride ourselves in writing programs to solve problems. However, it's very time consuming to write the programs to solve problems. Instead we should write programs to write programs to solve problems!
In this case, the problem is Kolmogorov Complexity. You must write a program that golfs a program, that outputs piece of text.
Main program -&gt; Generated program -&gt; Text
You do not necessarily need to golf the main program. Your score is the length of the generated program.

You will not know the final text when writing the main program. Therefore, you will not be able to write the generated program by hand. The main program should take a string input and create the generated program, which correctly outputs the text.

On February 12th, the first paragraph of the headline of the New York Times will be used for scoring. I will post the article at 10 AM ESThttps://www.nytimes.com/


You may use any language for the main program and generated program. They do not have to be the same.

The final text will never contain these characters: &quot;, ', \n, \r.

The main program is limited to 1024 bytes (not characters). The generated program has no byte limit, as long as it outputs the text.

Compression algorithms built in to your language are not allowed (both ways), unless you code it from scratch. This includes any type of text compression libraries, and base conversion. This does not include Regexes.

Standard loopholes apply.



Example: (JavaScript)
f=(g)=&gt;{console.log(&quot;console.log('&quot; + g + &quot;')&quot;)}
Retina, worst case (3+original length) bytes

EDIT: added support for newlines, in order to try this code in actual kolmogorov complexity challenges. Behaviour on strings without newlines remains unchanged.

Retina is great at substituting substrings, so that's what we're going to do!

This program looks for repeated sequences of characters and replaces them every time with a single character not appearing in the full string. The generated program then starts with the "compressed" string and applies all substitutions in reverse.

This code adds 3 bytes of boilerplate (a newline at the beginning, and a \` towards the end to suppress a trailing newline), so in the worst case (when there are no repeated sequences worth substituting) we have a length of 3 bytes more than the starting string. On average, this will shave a few bytes from the original length, not much but still a compression.

Here's the code with some comments:

First, we use a trick with transliteration ranges to change newlines into ¶, which is how newlines are printed in a Retina program

T`µ¶·`µ-·


then we start the main loop, duplicating the first line

{`^.+
$&amp;¶$&amp;


we only substitute when the sequence is repeated enough times (depending on its length)

^.*?((......+).*?\2|(.....?).*?\3.*?\3|(...).*?\4.*?\4.*?\4|(..).*?\5.*?\5.*?\5.*?\5.*?\5).*
"$2$3$4$5
^"(.+)|^.*
$+


to find a character not in the string, we append a list of candidates to the string, using " as separator, and then remove duplicates

^(.*)¶(.*)
$2" 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#%&amp;\'()*+,-./:;?@\^_`{|}~¶$2¶$1
D`(?&lt;=^.*).
^.*"(.)?.*¶(.+)
$2¶$1


here the actual substitution in the text happens

+`^(.*)(.+)(.*¶(.)¶\2(¶|$))
$1$4$3


in case we couldn't find a repeated sequence or an unused character, we restore the string to the original state (which makes us break from the loop)

}`(.*)¶(¶.*|.*¶)(¶|$)
$1$3


at the end, we add the 3 bytes of boilerplate

^
¶
\-1=`.*¶
\`$&amp;


Try it online!

In the linked example, the 292 bytes paragraph gets compressed to a 286 bytes Retina code.

NOTE: the substitutions made are not optimal, we just make every time the first suitable substitution we find; I don't know if an algorithm finding the optimal substitutions could run in a reasonable amount of time.