function converte(letras) {
var alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var codigos = [];
for (var i in letras) {
codigos.push(alfabeto.indexOf(removeAcento(letras[i].toUpperCase())) + 1);
}
return codigos;
}
function removeAcento(letra) {
var acentos = {
"ÁÅÃÀÂÄ" : "A",
"ÉÊÈË" : "E",
"ÍÎÌÏ" : "I",
"ÓÕÒÔÖ" : "O",
"ÚÙÛÜ" : "U",
"Ç" : "C"
};
for (var key in acentos) {
for (var a = 0; a < key.length; a++) {
if (letra === key[a]) {
return acentos[key];
}
}
}
return letra;
}
var resultado = converte("acdAé");
for (var i in resultado) {
print(resultado[i]);
}
ZnVuY3Rpb24gY29udmVydGUobGV0cmFzKSB7Cgl2YXIgYWxmYWJldG8gPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoiOwoJdmFyIGNvZGlnb3MgPSBbXTsKCWZvciAodmFyIGkgaW4gbGV0cmFzKSB7CgkJY29kaWdvcy5wdXNoKGFsZmFiZXRvLmluZGV4T2YocmVtb3ZlQWNlbnRvKGxldHJhc1tpXS50b1VwcGVyQ2FzZSgpKSkgKyAxKTsKCX0KCXJldHVybiBjb2RpZ29zOwp9CgpmdW5jdGlvbiByZW1vdmVBY2VudG8obGV0cmEpIHsKICB2YXIgYWNlbnRvcyA9IHsKICAgICLDgcOFw4PDgMOCw4QiIDogIkEiLAogICAgIsOJw4rDiMOLIiA6ICJFIiwKICAgICLDjcOOw4zDjyIgOiAiSSIsCiAgICAiw5PDlcOSw5TDliIgOiAiTyIsCiAgICAiw5rDmcObw5wiIDogIlUiLAogICAgIsOHIiA6ICJDIgogIH07CiAgZm9yICh2YXIga2V5IGluIGFjZW50b3MpIHsKICAgIGZvciAodmFyIGEgPSAwOyBhIDwga2V5Lmxlbmd0aDsgYSsrKSB7CiAgICAgIGlmIChsZXRyYSA9PT0ga2V5W2FdKSB7IAogICAgICAgICAgcmV0dXJuIGFjZW50b3Nba2V5XTsKICAgICAgfQogICAgfQogIH0KICByZXR1cm4gbGV0cmE7Cn0KCnZhciByZXN1bHRhZG8gPSBjb252ZXJ0ZSgiYWNkQcOpIik7CmZvciAodmFyIGkgaW4gcmVzdWx0YWRvKSB7CiAgICBwcmludChyZXN1bHRhZG9baV0pOwp9