Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reto #26 - Python #4187

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Retos/Reto #26 - TESTING [Media]/python/Lemito66.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
* Crea tres test sobre el reto 12: "Viernes 13".
* - Puedes copiar una solución ya creada por otro usuario en
* el lenguaje que estés utilizando.
* - Debes emplear un mecanismo de ejecución de test que posea
* el lenguaje de programación que hayas seleccionado.
* - Los tres test deben de funcionar y comprobar
* diferentes situaciones (a tu elección).
"""

import datetime
#Lemito66
def friday_thirteen(year: int, month: int) -> bool:
try:
return datetime.date(year,month,13).weekday() == 4 # weekday() return day of the week, where Monday == 0 ... Sunday == 6.
except:
return False

def test_one_friday_thirteen():
assert friday_thirteen(2022, 5) == True

def test_two_friday_thirteen():
assert friday_thirteen(2022, 4) == False

def test_three_friday_thirteen():
assert friday_thirteen(-1, 5) == False
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
* Crea una función que reciba dos cadenas de texto casi iguales,
* a excepción de uno o varios caracteres.
* La función debe encontrarlos y retornarlos en formato lista/array.
* - Ambas cadenas de texto deben ser iguales en longitud.
* - Las cadenas de texto son iguales elemento a elemento.
* - No se pueden utilizar operaciones propias del lenguaje
* que lo resuelvan directamente.
*
* Ejemplos:
* - Me llamo mouredev / Me llemo mouredov -> ["e", "o"]
* - Me llamo.Brais Moure / Me llamo brais moure -> [" ", "b", "m"]
"""

def find_difference(string_one: str , string_two: str) -> list:
difference = []
if len(string_one) != len(string_two):
return "Ambas cadenas de texto deben ser iguales en longitud."

for word in range(len(string_one)):
if string_one[word] != string_two[word]:
difference.append(string_two[word])
return difference

print(find_difference("Me llamo mouredev", "Me llemo mouredov"))
print(find_difference("Me llamo.Brais Moure", "Me llamo brais moure"))

print(find_difference('abc', 'abc'))
print(find_difference('abc', 'abcd'))
print(find_difference('a!b@c#', 'a!b@d#'))