From 49d36833b91e8b984d349c7ece7a4b90088e25af Mon Sep 17 00:00:00 2001 From: jmiguelmangas Date: Tue, 19 Sep 2023 15:07:50 +0200 Subject: [PATCH 1/7] primera version sin revision de dos letras --- .../python/jmiguelmangas.py" | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 "Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" diff --git "a/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" "b/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" new file mode 100644 index 0000000000..afa3db521a --- /dev/null +++ "b/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" @@ -0,0 +1,82 @@ +"""/* + * Crea una función que sea capaz de transformar Español al lenguaje básico del universo + * Star Wars: el "Aurebesh". + * - Puedes dejar sin transformar los caracteres que no existan en "Aurebesh". + * - También tiene que ser capaz de traducir en sentido contrario. + * + * ¿Lo has conseguido? Nómbrame en twitter.com/mouredev y escríbeme algo en Aurebesh. + * + * ¡Que la fuerza os acompañe! + */""" + +Aurebesh_alphabet = { + " ": " ", + "a": "aurek", + "b": "besh", + "c": "cresh", + "d": "dorn", + "e": "esk", + "f": "forn", + "g": "grek", + "h": "herf", + "i": "isk", + "j": "jenth", + "k": "krill", + "l": "leth", + "m": "mern", + "n": "nern", + "o": "osk", + "p": "peth", + "q": "qek", + "r": "resh", + "s": "senth", + "t": "trill", + "u": "usk", + "v": "vev", + "w": "wesk", + "x": "xesh", + "y": "yirt", + "z": "zerek", + "ae": "enth", + "ch": "cherek", + "eo": "onith", + "kh": "krenth", + "ng": "nen", + "oo": "orenth", + "sh": "shen", + "th": "thesh", +} +def get_sentence(): + return input("Escribe tu frase: ") + +def get_traduction(): + opcion = 0 + while opcion != 1 and opcion != 2: + print("1- Español -> Aurebesh\n2- Aurebesh -> Español\n") + try: + opcion = int(input("Introduce tu opcion: ")) + except ValueError: + print(opcion) + return opcion + +def spanish_aurenesh(sentence): + traduction_aurenesh = [] + two_letters = 0 + for character in sentence: + for i in Aurebesh_alphabet: + if character == i: + traduction_aurenesh.append(Aurebesh_alphabet[i]) + return traduction_aurenesh +def main(): + opcion = get_traduction() + sentence = get_sentence() + if opcion == 1: + list_aurenesh =(spanish_aurenesh(sentence)) + string_aurenesh = ''.join(map(str, list_aurenesh)) + print(string_aurenesh) +""" elif opcion == 2: + print(aurenesh_spanish(sentence))""" + + +if __name__ == "__main__": + main() \ No newline at end of file From 58778b8bfc85704bc8e02f8dbeeef26944859d3c Mon Sep 17 00:00:00 2001 From: jmiguelmangas Date: Tue, 19 Sep 2023 15:35:36 +0200 Subject: [PATCH 2/7] =?UTF-8?q?a=C3=B1adiendo=20funcionalidad=20de=20leer?= =?UTF-8?q?=20dos=20letras?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../python/jmiguelmangas.py" | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git "a/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" "b/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" index afa3db521a..f81bb81a97 100644 --- "a/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" +++ "b/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" @@ -61,11 +61,22 @@ def get_traduction(): def spanish_aurenesh(sentence): traduction_aurenesh = [] - two_letters = 0 - for character in sentence: + two = 0 + for i in range(len(sentence)): + character = sentence[i] + if i < (len(sentence))-1: + character_plus = sentence[i+1] + conjunction = character + character_plus + print(conjunction) for i in Aurebesh_alphabet: - if character == i: + if conjunction == i and two == 0: traduction_aurenesh.append(Aurebesh_alphabet[i]) + print("escribo dos letras") + two = 1 + elif conjunction != i and character == i and two == 0: + traduction_aurenesh.append(Aurebesh_alphabet[i]) + print("escribo una letra") + two = 0 return traduction_aurenesh def main(): opcion = get_traduction() From 20160701b821be803bf04c63a0e14b885d06d580 Mon Sep 17 00:00:00 2001 From: jmiguelmangas Date: Wed, 20 Sep 2023 13:14:32 +0200 Subject: [PATCH 3/7] Agregado Reto#15 python/jmiguelmangas.py --- .../python/jmiguelmangas.py" | 101 ++++++++++++------ 1 file changed, 66 insertions(+), 35 deletions(-) diff --git "a/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" "b/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" index f81bb81a97..e314a9b428 100644 --- "a/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" +++ "b/Retos/Reto #15 - AUREBESH [F\303\241cil]/python/jmiguelmangas.py" @@ -9,8 +9,16 @@ * ¡Que la fuerza os acompañe! */""" -Aurebesh_alphabet = { +Aurebesh_alphabet = { " ": " ", + "ae": "enth", + "ch": "cherek", + "eo": "onith", + "kh": "krenth", + "ng": "nen", + "oo": "orenth", + "sh": "shen", + "th": "thesh", "a": "aurek", "b": "besh", "c": "cresh", @@ -36,19 +44,14 @@ "w": "wesk", "x": "xesh", "y": "yirt", - "z": "zerek", - "ae": "enth", - "ch": "cherek", - "eo": "onith", - "kh": "krenth", - "ng": "nen", - "oo": "orenth", - "sh": "shen", - "th": "thesh", + "z": "zerek", } + + def get_sentence(): return input("Escribe tu frase: ") + def get_traduction(): opcion = 0 while opcion != 1 and opcion != 2: @@ -59,35 +62,63 @@ def get_traduction(): print(opcion) return opcion -def spanish_aurenesh(sentence): - traduction_aurenesh = [] - two = 0 + +def spanish_aurebesh(sentence): + traduction_aurebesh = [] + two_letters_sign = False + for i in range(len(sentence)): + character = sentence[i] + + if i < (len(sentence)) - 1: + character_plus = sentence[i + 1] + two_letters = character + character_plus + + if two_letters_sign == False: + for aurebesh_character in Aurebesh_alphabet: + if two_letters == aurebesh_character: + traduction_aurebesh.append(Aurebesh_alphabet[aurebesh_character]) + + two_letters_sign = True + break + elif ( + two_letters != aurebesh_character + and character == aurebesh_character + ): + traduction_aurebesh.append(Aurebesh_alphabet[aurebesh_character]) + else: + two_letters_sign = False + return traduction_aurebesh + + +def aurebesh_spanish(sentence): + traduction_spanish = [] + character_search = "" for i in range(len(sentence)): character = sentence[i] - if i < (len(sentence))-1: - character_plus = sentence[i+1] - conjunction = character + character_plus - print(conjunction) - for i in Aurebesh_alphabet: - if conjunction == i and two == 0: - traduction_aurenesh.append(Aurebesh_alphabet[i]) - print("escribo dos letras") - two = 1 - elif conjunction != i and character == i and two == 0: - traduction_aurenesh.append(Aurebesh_alphabet[i]) - print("escribo una letra") - two = 0 - return traduction_aurenesh + character_search = character_search + character + print(character_search) + for aurebesh_key, aurebesh_value in Aurebesh_alphabet.items(): + if character_search == aurebesh_value: + traduction_spanish.append(aurebesh_key) + character_search="" + + return traduction_spanish + + def main(): opcion = get_traduction() sentence = get_sentence() + if opcion == 1: - list_aurenesh =(spanish_aurenesh(sentence)) - string_aurenesh = ''.join(map(str, list_aurenesh)) - print(string_aurenesh) -""" elif opcion == 2: - print(aurenesh_spanish(sentence))""" - - + list_aurebesh = spanish_aurebesh(sentence) + string_aurebesh = "".join(map(str, list_aurebesh)) + print("Traducido a Aurebesh: ", string_aurebesh) + + elif opcion == 2: + list_spanish = aurebesh_spanish(sentence) + string_spanish = "".join(map(str, list_spanish)) + print("Traducido a Español: ", string_spanish) + + if __name__ == "__main__": - main() \ No newline at end of file + main() From f36162fd7ace3dc5e0067a24fbbb2bf6933e5c48 Mon Sep 17 00:00:00 2001 From: jmiguelmangas Date: Wed, 20 Sep 2023 13:28:07 +0200 Subject: [PATCH 4/7] primera version Reto 16, peticion numero escalones --- .../python/jmiguelmangas.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py diff --git a/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py b/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py new file mode 100644 index 0000000000..9dbb621f12 --- /dev/null +++ b/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py @@ -0,0 +1,29 @@ +"""/* + * Crea una función que dibuje una escalera según su número de escalones. + * - Si el número es positivo, será ascendente de izquiera a derecha. + * - Si el número es negativo, será descendente de izquiera a derecha. + * - Si el número es cero, se dibujarán dos guiones bajos (__). + * + * Ejemplo: 4 + * _ + * _| + * _| + * _| + * _| + * + */""" +import sys + +def get_number(): + + try: + steps = int(input("Numero de Escalones: ")) + except ValueError: + sys.exit("Tienes que introducir un numero negativo,positivo o 0") + +def main(): + number_steps = get_number() + +if __name__ == "__main__": + main() + \ No newline at end of file From e2c55b775d8a810402ce024822b3ae51759995cc Mon Sep 17 00:00:00 2001 From: jmiguelmangas Date: Wed, 20 Sep 2023 14:03:47 +0200 Subject: [PATCH 5/7] Implementados Escalones positivos, y 0 --- .../python/jmiguelmangas.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py b/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py index 9dbb621f12..25ddb2dd9f 100644 --- a/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py +++ b/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py @@ -17,12 +17,27 @@ def get_number(): try: - steps = int(input("Numero de Escalones: ")) + return int(input("Numero de Escalones: ")) except ValueError: - sys.exit("Tienes que introducir un numero negativo,positivo o 0") + sys.exit("Tienes que introducir un numero negativo,positivo u 0") + +def stair_constructor(number_steps): + + if number_steps != 0: + print_matrix(number_steps) + else: + print("__") + +def print_matrix(number_steps): + if number_steps > 0: + for step in range(number_steps): + if step == 0: + print((((number_steps-1)*2)-(step*2)+2)*" ","_") + print((((number_steps-1)*2)-(step*2))*" ","_|") def main(): number_steps = get_number() + stair_constructor(number_steps) if __name__ == "__main__": main() From 74382f50ee71b651a546cd3f75cc7b30bcd5e5db Mon Sep 17 00:00:00 2001 From: jmiguelmangas Date: Wed, 20 Sep 2023 14:14:42 +0200 Subject: [PATCH 6/7] Reto #16 python/jmiguelmangas.py Completo --- .../Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py b/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py index 25ddb2dd9f..08c3456cc1 100644 --- a/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py +++ b/Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py @@ -34,6 +34,12 @@ def print_matrix(number_steps): if step == 0: print((((number_steps-1)*2)-(step*2)+2)*" ","_") print((((number_steps-1)*2)-(step*2))*" ","_|") + else: + number_steps = abs(number_steps) + for step in range(number_steps): + if step == 0: + print((((step-1)*2)-(number_steps*2)+2)*" ","_") + print(((step*2)+1)*" ","|_") def main(): number_steps = get_number() From 2e61b688daabc9c34a64dcbec7024e55ceb5a660 Mon Sep 17 00:00:00 2001 From: jmiguelmangas Date: Wed, 20 Sep 2023 15:54:02 +0200 Subject: [PATCH 7/7] Reto 17 python/jmiguelmangas.py --- .../python/jmiguelmangas.py" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "Retos/Reto #17 - GIT Y GITHUB [Dif\303\255cil]/python/jmiguelmangas.py" diff --git "a/Retos/Reto #17 - GIT Y GITHUB [Dif\303\255cil]/python/jmiguelmangas.py" "b/Retos/Reto #17 - GIT Y GITHUB [Dif\303\255cil]/python/jmiguelmangas.py" new file mode 100644 index 0000000000..e3c713f6ee --- /dev/null +++ "b/Retos/Reto #17 - GIT Y GITHUB [Dif\303\255cil]/python/jmiguelmangas.py" @@ -0,0 +1,44 @@ +# Reto #17: Git y GitHub +"""/* + * ¡Estoy de celebración! He publicado mi primer libro: + * "Git y GitHub desde cero" + * - Papel: mouredev.com/libro-git + * - eBook: mouredev.com/ebook-git + * + * ¿Sabías que puedes leer información de Git y GitHub desde la gran + * mayoría de lenguajes de programación? + * + * Crea un programa que lea los últimos 10 commits de este repositorio y muestre: + * - Hash + * - Autor + * - Mensaje + * - Fecha y hora + * + * Ejemplo de salida: + * Commit 1 (el más reciente) | 12345A | MoureDev | Este es un commit | 24/04/2023 21:00 + * + * Se permite utilizar librerías que nos faciliten esta tarea. + * + */""" + +from git import Repo +import time + +repo_url = "https://github.com/mouredev/retos-programacion-2023" + +repo = Repo("/users/jmiguelmangas/git_prueba") + +tree = repo.head.commit.tree + +prev_commits = [ + c for c in repo.iter_commits(all=True, max_count=10) +] # last 10 commits from all branches + +i = 1 +for commit in prev_commits: + hora1 = time.asctime(time.gmtime(commit.committed_date)) + hora2 = time.strftime("%a, %d %b %Y %H:%M", time.gmtime(commit.committed_date)) + print( + f"Numero de Commit {i} Hash: {commit} \nAutor {commit.author.name} \nMensaje: {commit.message} \nFecha: {hora1}\n\n" + ) + i += 1