Skip to content

Commit

Permalink
Reto mouredev#9 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
rokmanhaman committed Nov 17, 2023
1 parent 3b68fed commit 4ccdc1d
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def check_primo(self):



n= Number(7)
n= Number(17)

print(f"{n.value} {n.check_primo()}, {n.check_fibonacci()} y {n.check_even()}")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""Reto #9: HETEROGRAMA, ISOGRAMA Y PANGRAMA
FÁCIL | Publicación: 27/02/23 | Resolución: 06/03/23
/*
* Crea 3 funciones, cada una encargada de detectar si una cadena de
* texto es un heterograma, un isograma o un pangrama.
* - Debes buscar la definición de cada uno de estos términos.
*/"""

# HETEROGRAMA: palabra o frase que no contiene ninguna letra repetida.
# ISOGRAMA: palabra o frase en la que cada letra aparece el mismo número de veces
# PANGRAMA: es un texto que usa todas las letras posibles del alfabeto de un idioma

import string

class MyText():

def __init__(self, text):
self.text = text

def is_heterograma(self):
text_without_spaces = self.text.replace(" ", "")
text_without_duplicated = set(text_without_spaces)

ocurrencias = {
text_without_duplicated:
self.text.count(text_without_duplicated)
for text_without_duplicated in text_without_duplicated}

max_occ = max(ocurrencias.values())

return "es HETEROGRAMA" if max_occ == 1 else "no es HETEROGRAMA"

def is_isograma(self):
text_without_spaces = self.text.replace(" ", "")
text_without_duplicated = set(text_without_spaces)

ocurrencias = {
text_without_duplicated:
self.text.count(text_without_duplicated)
for text_without_duplicated in text_without_duplicated}

lista = list(ocurrencias.values())
check = True
for index, val in enumerate(lista):
check = lista[index] == lista[0] and check

return "es ISOGRAMA" if check == True else "no es ISOGRAMA"

def is_pangrama(self):
text_without_spaces = self.text.replace(" ", "")
text_without_duplicated = set(text_without_spaces)
lpos = string.ascii_lowercase

check = True
for l in lpos:
if l in text_without_duplicated:
check = True and check
else:
check = False



return "es PANGRAMA" if check == True else "no es PANGRAMA"


#frase = "murciélago"
#frase = "mama"
frase = "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"

f = MyText(frase)
print(f.is_heterograma())
print(f.is_isograma())
print(f.is_pangrama())

0 comments on commit 4ccdc1d

Please sign in to comment.