Skip to content

Commit

Permalink
Merge pull request #5053 from jmiguelmangas/main
Browse files Browse the repository at this point in the history
Reto #15 #16 #17 Python/jmiguelmangas.py Terminado
  • Loading branch information
kontroldev authored Sep 21, 2023
2 parents 27d7662 + 2e61b68 commit 49c6c81
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 0 deletions.
124 changes: 124 additions & 0 deletions Retos/Reto #15 - AUREBESH [Fácil]/python/jmiguelmangas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
"""/*
* 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 = {
" ": " ",
"ae": "enth",
"ch": "cherek",
"eo": "onith",
"kh": "krenth",
"ng": "nen",
"oo": "orenth",
"sh": "shen",
"th": "thesh",
"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",
}


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_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]
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_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()
50 changes: 50 additions & 0 deletions Retos/Reto #16 - LA ESCALERA [Media]/python/jmiguelmangas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""/*
* 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:
return int(input("Numero de Escalones: "))
except ValueError:
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))*" ","_|")
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()
stair_constructor(number_steps)

if __name__ == "__main__":
main()

44 changes: 44 additions & 0 deletions Retos/Reto #17 - GIT Y GITHUB [Difícil]/python/jmiguelmangas.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 49c6c81

Please sign in to comment.