Skip to content

Instantly share code, notes, and snippets.

@juanfal
Last active November 18, 2022 12:37
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 juanfal/63cabaaaee15bac6ad2016b6f6eed39d to your computer and use it in GitHub Desktop.
Save juanfal/63cabaaaee15bac6ad2016b6f6eed39d to your computer and use it in GitHub Desktop.
mismo conjunto de letras en dos cadenas sin funciones de python
# t08.mismoConjuntodeletras.py
# juanfc 2020-12-09
# https://gist.github.com/63cabaaaee15bac6ad2016b6f6eed39d
def estaEn(cad, let):
i = 0
while i < len(cad) and cad[i] != let:
i += 1
return i < len(cad)
def mismoConjuntodeletras(a, b):
porAhora = True
i = 0
while i < len(a) and porAhora:
porAhora = estaEn(b, a[i])
i+=1
i = 0
while i < len(b) and porAhora:
porAhora = estaEn(a, b[i])
i+=1
return porAhora
def printPruebas(s1, s2):
if mismoConjuntodeletras(s1, s2):
print(f"{s1} <===> {s2}")
else:
print(f"{s1} <=/=> {s2}")
# -----------
printPruebas("mirarroma", "amorio")
printPruebas("mxrarroma", "amorio")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment