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:
collectedRows.map(pokemon => pokemon.num + ";" + pokemon.etymology.join(",").replace(/\,$/, '') + ";" + pokemon.name).join("\n")
Examples:
The full list of test cases can be found at the pastebin link, but here are some example inputs and outputs:
1, ['bulb', '-saur'] --> 'bulbasaur'
122, ['mr.', 'mime artist'] --> 'mr. mime'
29, ['nidoru' ,'rhino', '♀'] --> 'nidoran♀'
16, ['pigeon'] --> 'pidgey'
17, ['pigeon'] --> 'pidgeotto'
23, ['snake'] --> 'ekans'
Note that due to 'nidoran♀' and its family, you need to be able to handle input/output in UTF-8.
The winner is the entry with the highest accuracy, with ties broken by code length. In practice, this means that the challenge is code-golf -- you need to get 100% accuracy to be a competitive entry -- since you can trivially create a lookup table, but feel free to post a sub-100% accuracy answer if you think it does something creative (someone else might extend it to handle the edge cases).
If you wish, you may also include a data file, and the number of bytes of that file is added to your byte count. This is just if you want to keep your code and data separate.
16, ['pigeon'] --> 'pidgey'
,17, ['pigeon'] --> 'pidgeotto'
. So, sometimes you need the number. \$\endgroup\$