/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
HashMap
<String, Integer
> hashLetras
=new HashMap
<String, Integer
>();
hashLetras.put("A", 2);
hashLetras.put("B", 3);
hashLetras.put("C", 4);
hashLetras.put("D", 5);
hashLetras.put("E", 3);
hashLetras.put("F", 4);
hashLetras.put("G", 5);
hashLetras.put("H", 6);
hashLetras.put("I", 4);
hashLetras.put("J", 5);
hashLetras.put("K", 6);
hashLetras.put("L", 7);
hashLetras.put("M", 8);
hashLetras.put("N", 9);
hashLetras.put("O", 5);
hashLetras.put("P", 6);
hashLetras.put("Q", 7);
hashLetras.put("R", 8);
hashLetras.put("S", 9);
hashLetras.put("T", 10);
hashLetras.put("U", 6);
hashLetras.put("V", 7);
hashLetras.put("W", 8);
hashLetras.put("X", 9);
hashLetras.put("Y", 10);
hashLetras.put("Z", 11);
hashLetras.put(" ", 7); //ESPACO
hashLetras.put("QU", 7);
int count=0;
for(int i=0; i<teste.length();i++){
int pontosDuasLetras = 0;
if (i < teste.length() - 1){ //se tem pelo menos mais uma letra para a frente
String duasLetras
= "" + teste.
charAt(i
) + teste.
charAt(i
+ 1); if (hashLetras.containsKey(duasLetras)){
pontosDuasLetras = hashLetras.get(duasLetras);
i++; //avança logo as duas letras
}
}
count += pontosDuasLetras == 0 ? hashLetras.get("" + teste.charAt(i)) : pontosDuasLetras;
}
System.
out.
println("O tempo foi de: "+count
); }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1Ymxp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