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 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.

• This is a very nice question imho. – Anush Jan 4 at 13:45
• 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 Jan 9 at 1:08
• @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 Jan 9 at 1:13
• Is Japt a valid caddie for JavaScript? – user85052 Jan 11 at 14:46
• @a'_' - If there's a program E that converts from JavaScript to Japt, then it's valid, yes. – Dustin G. Mixon Jan 11 at 23:11

# Score: $$\\frac{38}{224}\approx0.17\$$ (with newlines removed)

## Program E

from textwrap import wrap

x = input('Code: ')
i = ['<', '>', '+', '-', '[', ']', '.', ',']
o = ''
for c in x:
if c in i:
o += str(i.index(c) + 1)
if o:
d = wrap(o, 6)
d = [int(x) for x in d]
o = ''
for c in d:
o += chr(int(c) + 128)
print('Compressed: ', o)



The way this works is by converting every instruction in the input to a digit, then concatenating those digits to a number. Then it splits that number into 6-digit groups and converts each to a Unicode character. (A number higher than 6 could be used, by that would cause errors for large programs). Then it outputs it.

## Program D

x = input('Compressed: ')
p = input('Input: ')
p = list(p)
d = ''
for c in x:
c = ord(c) - 128
d += str(c)
d = d.replace('-', '')
i = ['<', '>', '+', '-', '[', ']', '.', ',']
o = ''
for n in d:
n = int(n) - 1
o += i[n]
tape =  * 30000
m = {}
m2 = {}
stack = []
for i in range(len(o)):
char = o[i]
if char == '[':
stack.append(i)
elif char == ']':
begin = stack.pop()
m[begin] = i + 1
m2[i] = begin
i = 0
while i < len(o):
char = o[i]
if char == '<':
i += 1
elif char == '>':
i += 1
elif char == '+':
i += 1
elif char == '-':
i += 1
elif char == '[':
i = m[i]
else:
i += 1
elif char == ']':
i = m2[i]
else:
i += 1
elif char == '.':
i += 1
elif char == ',':
try: