-
-
Save parzibyte/28780e4d5b70ead025aed744a5db8b37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String obtenerPistas(String suposicionPassword, String passwordCorrecto) { | |
String pistas = ""; | |
for (int x = 0; x < suposicionPassword.length(); x++) { | |
// Si está en el lugar correcto se indica con un * | |
if (suposicionPassword.charAt(x) == passwordCorrecto.charAt(x)) { | |
pistas += "*"; | |
continue; | |
} | |
// Si está en la cadena pero no en el lugar correcto, se indica con un _ | |
int indiceCaracter = passwordCorrecto.indexOf(suposicionPassword.charAt(x)); | |
if (indiceCaracter != -1) { | |
pistas += "_"; | |
continue; | |
} | |
// Finalmente, si ninguna de las condiciones de arriba se cumple, el carácter no | |
// está | |
pistas += " "; | |
} | |
return pistas; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment