Make a Unicorn interpreter

Unicorn (ES6), 5934 5278 bytes

Under the custom encoding, this is 5278 bytes (1 byte per char); but with UTF-8, it would 4 bytes per char (though only 1 for a space), or 20869 total.

(too many Unicorns and Goats to reasonably display here)

Instead, here's a pastebin. This Unicorn code transpiles to this JS snippet:

s=>eval(s.replace(/\S+ ?/g,c=>String.fromCharCode(c.length>>1<<c.charCodeAt()%2)))

Now, this isn't the shortest possible version; this is shorter:

s=>eval(s.replace(/\S+ ?/g,c=>String.fromCharCode(c.length>>1<<("">c))))

However, the one unicorn in there would transpile to 56034 goats, thus multiplying the score by roughly 11.

Here's the function I used to transpile to Unicorn:

function g(s){return s.replace(/./g,function(c){i=c.charCodeAt();return(i%2?"".repeat(i):"".repeat(i/2))+" "}).slice(0,-1)}
<textarea id=O cols=100></textarea><button id=P onclick="Q.value=g(O.value);R.innerHTML=(Q.value.length+Q.value.split(' ').length-1)/2">Run</button><br><textarea id=Q rows=10 cols=100>Output appears here.</textarea><br><p>Length: <span id=R>0</span><br></p>

Note: I haven't actually tested the program, as there isn't an online interpreter that I could find (although I suppose I could hook up the .js file to HTML...?)


Pyth - 23 17 bytes

.vsmC+/d\y/d\cz

Try it online.

It works by splitting the input by spaces, then for each section counting the number of unicorns and number of goats * 2 then adding them, then taking the char at the code point. It finished by summing the char array and pyth-evaling.


Python 179 176 bytes

EDIT: I just learnt s.split(' ')=s.split()

Here is the second "actual" programming language Unicorn interpreter. I call this version of Unicorn "UnicornPy" pronounced as "unicorn pie". I am making this much too official!

s=raw_input()
s=s.replace('','')
s=s.replace('','u')
for i in s:
    if i not in "ug ":
        s=s.replace(i,'')
s=s.split()
for i in s:
    s[s.index(i)]=chr(len(i))
exec(''.join(s))

For some reason, it needs me to convert the unicorn and goat emojis to u and g. I do not know why.

Try it here!