9
3
In golf, a knowledgable caddie helps an already good golfer to be even better. In this challenge, you build a "caddie" to help you code golf. In particular, your caddie will compress golfed code in such a way that another program can uncompress and then run the code. A good caddie will compress golfed code to be much smaller than the original golfed code. In fact, in caddie-assisted Python (say), you might be able to golf on par with a Jelly golfer!
Formally, a caddie for a language L is a pair (E,D) of programs. The program E takes as input any code c in L and outputs a string s. The program D takes s as input along with any input x of c and returns the output of c(x). We do not require E and D to be written in L. You could say that E is a transpiler that converts c into a version s that runs in the language D. We are interested in transpilers E for which E(c) tends to be smaller than c, even when c is already golfed.
Write a caddie (E,D) for any language L of your choosing. When you first post a caddie here, its score is infinity. Use the following method to update your score:
- Let C denote the challenge in code-golf with at least 10 points that was posted first after your submission.
- Let c denote the shortest posted solution to C that is written in L.
- Your score is infinity unless C and c both exist, at which point your score is size(E(c))/size(c).
Recompute your score whenever either C or c changes. Lowest score wins.
1This is a very nice question imho. – Anush – 2020-01-04T13:45:14.213
I am a bit confused about "The program D takes s as input along with any input x of c and returns the output of c(x)." Does this just mean that D is the inverse of E? Or does D have to work for any caddy? – sugarfi – 2020-01-09T01:08:51.733
@sugarfi - D is designed with E, for E. One possibility is that D uncompresses s to obtain c and then evaluates c on input x. Yes, this conversion from s to c can be thought of as the inverse of E. – Dustin G. Mixon – 2020-01-09T01:13:08.810
Is Japt a valid caddie for JavaScript?
– None – 2020-01-11T14:46:03.773@a'_' - If there's a program E that converts from JavaScript to Japt, then it's valid, yes. – Dustin G. Mixon – 2020-01-11T23:11:22.263
I have a question about the string
s
- can it be effectively binary - a set of bytes with values of 0-255 - or should it be restricted to 'bytes that can be printed'. Is it envisioned thats
can be printed as 'code
' in a Code-Golf post? Do you have a list of characters we should not use? Oh and great challenge. – tom – 2020-01-13T01:03:42.853@tom - I'm not so picky about
s
. A set of bytes with values of 0-255 will suffice for this challenge. – Dustin G. Mixon – 2020-01-13T01:19:41.653