Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 27, 2020 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/63d28c0618278290b504fb365a751175 to your computer and use it in GitHub Desktop.
Save parzibyte/63d28c0618278290b504fb365a751175 to your computer and use it in GitHub Desktop.
/*
____ _____ _ _ _
| _ \ | __ \ (_) | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___|
__/ | __/ |
|___/ |___/
Blog: https://parzibyte.me/blog
Ayuda: https://parzibyte.me/blog/contrataciones-ayuda/
Contacto: https://parzibyte.me/blog/contacto/
Copyright (c) 2020 Luis Cabrera Benito
Licenciado bajo la licencia MIT
El texto de arriba debe ser incluido en cualquier redistribucion
*/
public class Main {
public static void main(String[] args) {
String cadenasParaProbar[] = { "Mi hijo degustó en el festival de bayas una extraña pizza de kiwi con queso",
"Hola",
"El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja",
"ABCDEFGHIJKLMNÑOPQRSTUVWXYZ", // Debería ser true
"ABCDEFGHIJKLMNÑOPQRSTUVWXY", // Sin Z
};
for (String cadena : cadenasParaProbar) {
System.out.printf("La cadena '%s' es pangrama? %b\n", cadena, esPangrama(cadena));
}
}
public static boolean esPangrama(String cadena) {
cadena = cadena.toUpperCase(); // Convertir a mayúscula para simplificar comparaciones
String letrasDelAlfabeto = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ";
for (int x = 0; x < letrasDelAlfabeto.length(); x++) {
if (!cadena.contains(Character.toString(letrasDelAlfabeto.charAt(x)))) {
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment