# Who's that pokemon (based on its etymology)?

As we all know, most Pokemon are created by combining some English (or Japanese) words; these words are the Pokemon's "etymology." For example, "charmander" is "char" and "salamander" put together.

Your task is, given a Pokemon's etymology and number, output the original Pokemon name. A short answer will be able to compress the 890 Pokemon into much fewer characters by exploiting the fact that the etymologies and the names themselves use mostly the same characters.

Input: The Pokemon number, and an array/list of etymologies, all lowercase

Output: The Pokemon's name, also lowercase

The full list of test cases can be found here: https://pastebin.com/B3rRdiPn. Each line is a test case with the format:

<pokemon number>;<comma separated etymology list>;<pokemon name>


This list was created from https://pokemondb.net/etymology by running the following code:

let collectedRows = [];
let rows = $(".data-table tr").slice(1) let isOddPrev = false; // Replacements due to typos, remove 'palindrome' since girafig doesn't come from the word 'palindrome', 'palindrome' is just a descriptor var repl = {"anacondo": "anaconda", "armadilo": "armadillo", "[palindrome]": ""} rows.each((_, row) => { let isOdd = row.classList.contains("odd"); let etym =$(row).find(".cell-etym-word").text().toLowerCase();
if (repl.hasOwnProperty(etym)) etym = repl[etym];
if (isOdd !== isOddPrev) {
collectedRows.push({name: $(row).find(".cell-name").text().toLowerCase(), etymology: [etym], num: parseInt($(row).find(".cell-num").text().replace(/\s/g, ''), 10)});
} else {
collectedRows[collectedRows.length - 1].etymology.push(etym);
}

isOddPrev = isOdd;
});

// Output:
f=lambda n,e:e[:int(p[n*2-2])]+zlib.decompress(b('c$&LLAIkf47^G<db8?T%yMocKrwCL>oK#<n&WzC%=10Fg#-{RjE{{jH9}U@g|%yNWEqE)HJts9&XORW7llzcxPyJopCGOuB9+zCT-S6_pQP;6F^(e9bB)uONv#HNp!Ac#IcdPUI7bnG@!S^6|xQJhv3bqI34r7Zi3t<f6PnFI0e#YAHR&r*7l;i{?%POa=UQSb4iuP=D7P(ch6tB%%CWB&T^u+MF0zO91dI5l^8b@I0-DyecX{vtX!15NapfuU-Vat9Zd{c;9Hvq!=UkLWm?0JH>roy%97}g^(|T7P6^&zhAOyaRx)wvn~E~UmPibD2onAkv@UsF*$)murb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('%')[n-1]+e[len(e)-int(p[n*2-1]):]  Try it online! Based on idea of @dingledooper (thanks!), but making it a step further by using the longest common suffix to help as well. Also used zlib & base85 to further reduce size a bit. # Python 3, 100%, 3817 ... 2463 2351 bytes import base64,bz2,re def f(n,e): s=re.findall("[A-Z].+?(?=[A-Z])",str(bz2.decompress(base64.b85decode("LRx4!F+o-Q(2lYjJyB>_?>2gMW}e@IU|m@L&gzfB<{l>MaducV>;xcV1v3r}_v9qd}l1g$bb0WFnp>O&STHDd{yaqyPYlr~6YAQwdMh*(7?5KmarbspRyU5D6YB>Ux_~Kpvn20BND4Mk62^05mXaen^xm000000ENyXhobxV;X?{ExyPLkgLKDP|*Q^?o*e5XuP4M=5UaiAd|2;!L-!vGCJPj#;Mo=2>TVCBV{l6DI6B_r0dGFBRQ-O|~xNM7ayY%9|*JDHKx)H%3m$P%bfxU(EeEGzleQ$#&o^1*0>mQyWinz&K_h&|r)n^J<>jzrwUxNpN$qXir0}FVs_7L(Ks|=pmD2iIahTy>RB*k9#U=BSIWVqS3gGbVZpVtyD8dEs&<v#@cP}dhnW7qib>cvCEjl7e+vZP!cd9feP7KUJ||~0FQFad}w6bGbS;17~RfNW=AZ-?8t28AOz_wt~OR85Loar%*#lVF{BpPkTAlKBBJq&5IIzogmT3wP=ZP{!d>aETG<_DSc2Oj4duuj%a?ggAaH<lR3|AC9N>Wyq;np^W5GyusED9MYY}3laCeQ@R052^8Lt6chhHS=PKG_o@*~ICBX~8XnxM69}KpBRk}!|Nkn*aP*I+cKKWij;l3&FfZofSuJl}P%9C^dABC%JEw(S#R(||vwYR%OltbAF<bRs2UeKzeXleyw=czoWGHjSn^SmprWPH?|!-=07#O)v9FyZb)D!mGeg_aEbQnWd~Sv^0$(U>TLiQx_d0ZJEj?In+L@K%YQUM1cbI1*C-ukR(DngIFmkJ^qE)Dc7>Wf?7YWLwM+J3Hpu;F&p=WjHW=<cygYHc+}GOFgXO0=*q=k*RxL<?d{EH8V4goTFz#A1JX|L%1mW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rV6BP@&gj9>5W^oRe^l@a-MKjx!_Em$F2!;9_1iF}v7FOAU5MhebG!cm!#tDiAHx_=BBoyR~nT-<02#y;N1qH_>8^t3Gu2k+kP#9cRS>VnNLqLE|Fyulvo#c=FH6J$2A-0V!(nsHf$#pb$SzC+bx%8>H$mCL5MtK&@WCh^k#Bi<=$%9ljrqSIqYVXCLeT0UO8{)!sRB>f->^P%M|mf^+&6ALwl)hsRm$4<rgGU<1DfY8|KjdQrwS4iMiG~Q"))))[n-1]
return e[:ord(s[0])-65]+s[2:]+e[len(e)-int(s[1]):]


Try it online!

## Explanation

We could print all of the Pokemon with just the number, but the etymology allows us to improve the compression algorithm. Take the first input: 1;bulb,-saur;bulbasaur. The first etymology bulb and the actual Pokemon have a common prefix. Most Pokemon in the list also have this property. So instead of compressing the entire name of the Pokemon, we only compress the right half of it (asaur in the example), starting from the longest common prefix of it and the first etymology. Then for the left half we can just directly take a prefix of the first etymology (bulb in the example). We also precompute the longest common suffix to further reduce the size. Then, we will encode the string like this: 44a. The first and second characters represent the longest common prefix and suffix. The rest represent the rest of the characters not accounted.

• I think changing base64 to base85 could shave a few hundred bytes? – newbie Apr 7 at 1:23
• Good point, I didn't even know that existed! :P – dingledooper Apr 7 at 1:28

# Pyke, 100%, 835 bytes

Sorry folks, Pyke contains a built-in Pokémon dictionary. Unfortunately, it only contains up to #802: marshadow, so 88 names had to be hard-coded.

Should work for all inputs, but the TIO environment seems to have a slightly different version of Pyke than on the "Pyke Interpreter" website, so inputs greater than 802 only work on the latter (see below).

Q0@802>"poipole,naganadel,stakataka,blacephalon,zeraora,meltan,melmetal,grookey,thwackey,rillaboom,scorbunny,raboot,cinderace,sobble,drizzile,inteleon,skwovet,greedent,rookidee,corvisquire,corviknight,blipbug,dottler,orbeetle,nickit,thievul,gossifleur,eldegoss,wooloo,dubwool,chewtle,drednaw,yamper,boltund,rolycoly,carkol,coalossal,applin,flapple,appletun,silicobra,sandaconda,cramorant,arrokuda,barraskewda,toxel,toxtricity,sizzlipede,centiskorch,clobbopus,grapploct,sinistea,polteageist,hatenna,hattrem,hatterene,impidimp,morgrem,grimmsnarl,obstagoon,perrserker,cursola,sirfetch'd,mr. rime,runerigus,milcery,alcremie,falinks,pincurchin,snom,frosmoth,stonjourner,eiscue,indeedee,morpeko,cufant,copperajah,dracozolt,arctozolt,dracovish,arctovish,duraludon,dreepy,drakloak,dragapult,zacian,zamazenta,eternatus"\,cQ0@803-@&Q0@~_+1-.ol1|


Try it here! (This site doesn't seem to support unicode, so output for nidoran♀ will be in UTF-8)

Try it online! (Supports unicode, but throws an error for inputs > 802)

Takes input in the form [1, "bulb", "-saur"]

Some relevant portions of the program:

Q0@


Read from STDIN, ignoring everything besides the pokemon number

Q0@802>...&


IF (pokemon #) > 802, Do the following:

"poipole,naganadel..."


- Using this long string of hardcoded names,

\,c


-- split on commas, and

Q0@803-@


-- return the name at index ((pokemon #) - 803)

Q0@~_+1-...|


ELSE: Find the index of this pokemon in the dictionary

.o


- Lookup in the built-in pokemon dictionary, and:

l1


- convert to lowercase, implicitly print