Skip to content

Commit 888d786

Browse files
committed
Corrección Roadmap 43 + Nuevo ejercicio 44
1 parent 6cdf3f2 commit 888d786

File tree

3 files changed

+166
-3
lines changed

3 files changed

+166
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
2828
## Corrección y próximo ejercicio
2929

30-
> #### Lunes 4 de noviembre de 2024 a las 20:00 (hora España) desde **[Twitch](https://twitch.tv/mouredev)**
31-
> #### Consulta el **[horario](https://discord.gg/mouredev?event=1295447627529326743)** por país y crea un **[recordatorio](https://discord.gg/mouredev?event=1295447627529326743)**
30+
> #### Lunes 11 de noviembre de 2024 a las 20:00 (hora España) desde **[Twitch](https://twitch.tv/mouredev)**
31+
> #### Consulta el **[horario](https://discord.gg/bDgt5Zjk?event=1300807174523457676)** por país y crea un **[recordatorio](https://discord.gg/bDgt5Zjk?event=1300807174523457676)**
3232
3333
## Roadmap
3434

@@ -77,7 +77,8 @@
7777
|40|[FORTNITE RUBIUS CUP](./Roadmap/40%20-%20FORTNITE%20RUBIUS%20CUP/ejercicio.md)|[📝](./Roadmap/40%20-%20FORTNITE%20RUBIUS%20CUP/python/mouredev.py)|[▶️](https://youtu.be/UlWtFvLLSXw)|[👥](./Roadmap/40%20-%20FORTNITE%20RUBIUS%20CUP/)
7878
|41|[CAMISETA RAR](./Roadmap/41%20-%20CAMISETA%20RAR/ejercicio.md)|[📝](./Roadmap/41%20-%20CAMISETA%20RAR/python/mouredev.py)|[▶️](https://youtu.be/QXFrWIFCkGY)|[👥](./Roadmap/41%20-%20CAMISETA%20RAR/)
7979
|42|[TORNEO DRAGON BALL](./Roadmap/42%20-%20TORNEO%20DRAGON%20BALL/ejercicio.md)|[📝](./Roadmap/42%20-%20TORNEO%20DRAGON%20BALL/python/mouredev.py)|[▶️](https://youtu.be/SgwX7ISEkvM)|[👥](./Roadmap/42%20-%20TORNEO%20DRAGON%20BALL/)
80-
|43|[GIT GITHUB CLI](./Roadmap/43%20-%20GIT%20GITHUB%20CLI/ejercicio.md)|[🗓️ 04/11/24](https://discord.gg/mouredev?event=1295447627529326743)||[👥](./Roadmap/43%20-%20GIT%20GITHUB%20CLI/)
80+
|43|[GIT GITHUB CLI](./Roadmap/43%20-%20GIT%20GITHUB%20CLI/ejercicio.md)|[📝](./Roadmap/43%20-%20GIT%20GITHUB%20CLI/)||[👥](./Roadmap/43%20-%20GIT%20GITHUB%20CLI/python/mouredev.py)
81+
|44|[CUENTA ATRÁS MOUREDEV PRO](./Roadmap/44%20-%20CUENTA%20ATRÁS%20MOUREDEV%20PRO/ejercicio.md)|[🗓️ 11/11/24](https://discord.gg/bDgt5Zjk?event=1300807174523457676)||[👥](./Roadmap/44%20-%20CUENTA%20ATRÁS%20MOUREDEV%20PRO/)
8182

8283
## Cursos en YouTube
8384

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import os
2+
from pdb import run
3+
import subprocess
4+
5+
6+
def run_command(command: str):
7+
8+
try:
9+
result = subprocess.run(
10+
command,
11+
shell=True,
12+
check=True,
13+
text=True,
14+
capture_output=True
15+
)
16+
print(result.stdout.strip())
17+
except subprocess.CalledProcessError as e:
18+
print(f"Error: {e.stderr.strip()}")
19+
20+
21+
def set_working_directory():
22+
23+
path = input("Introduce el directorio completo de trabajo: ")
24+
if os.path.isdir(path):
25+
os.chdir(path)
26+
print(f"El directorio de trabajo ha cambiado a: {path}")
27+
else:
28+
print("El directorio introducido no existe.")
29+
30+
31+
def create_repository():
32+
if os.path.isdir(".git"):
33+
print("Ya existe un repositorio en este directorio.")
34+
else:
35+
run_command("git init")
36+
run_command("git branch -M main")
37+
print("Repositorio inicializado.")
38+
39+
40+
def create_branch():
41+
branch_name = input("Nombre de la nueva rama: ")
42+
run_command(f"git branch {branch_name}")
43+
44+
45+
def switch_branch():
46+
branch_name = input("Nombre de la rama a la que quieres cambiar: ")
47+
run_command(f"git checkout {branch_name}")
48+
49+
50+
def show_pending_files():
51+
run_command("git status -s")
52+
53+
54+
def make_commit():
55+
message = input("Mensaje para el commit: ")
56+
run_command("git add .")
57+
run_command(f"git commit -m \"{message}\"")
58+
59+
60+
def show_commit_history():
61+
run_command("git log --oneline")
62+
63+
64+
def delete_branch():
65+
branch_name = input("Nombre de la rama a eliminar: ")
66+
run_command(f"git branch -d {branch_name}")
67+
68+
69+
def set_remote_repository():
70+
remote_url = input("URL del repositorio remoto: ")
71+
run_command(f"git remote add origin {remote_url}")
72+
run_command("git push -u origin main")
73+
74+
75+
def make_pull():
76+
run_command("git pull")
77+
78+
79+
def make_push():
80+
run_command("git push")
81+
82+
83+
while True:
84+
85+
print("\nDirectorio actual de trabajo:")
86+
run_command("pwd")
87+
88+
print("\nGit y GitHub CLI - Opciones:")
89+
print("1. Establecer el directorio de trabajo")
90+
print("2. Crear un nuevo repositorio")
91+
print("3. Crear una nueva rama")
92+
print("4. Cambiar de rama")
93+
print("5. Mostrar ficheros pendientes de hacer commit")
94+
print("6. Hacer commit (+add)")
95+
print("7. Mostrar el historial de commits")
96+
print("8. Eliminar rama")
97+
print("9. Establecer repositorio remoto")
98+
print("10. Hacer pull")
99+
print("11. Hacer push")
100+
print("12. Salir")
101+
102+
choice = input("Selecciona una opción (1 al 12): ")
103+
104+
match choice:
105+
case "1":
106+
set_working_directory()
107+
case "2":
108+
create_repository()
109+
case "3":
110+
create_branch()
111+
case "4":
112+
switch_branch()
113+
case "5":
114+
show_pending_files()
115+
case "6":
116+
make_commit()
117+
case "7":
118+
show_commit_history()
119+
case "8":
120+
delete_branch()
121+
case "9":
122+
set_remote_repository()
123+
case "10":
124+
make_pull()
125+
case "11":
126+
make_push()
127+
case "12":
128+
print("Saliendo...")
129+
break
130+
case _:
131+
print("Opción no válida.")
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# #44 CUENTA ATRÁS MOUREDEV PRO
2+
> #### Dificultad: Fácil | Publicación: 04/11/24 | Corrección: 11/11/24
3+
4+
## Ejercicio
5+
6+
```
7+
/*
8+
* EJERCICIO:
9+
* ¡El 12 de noviembre lanzo mouredev pro!
10+
* El campus de la comunidad para estudiar programación de
11+
* una manera diferente: https://mouredev.pro
12+
*
13+
* Crea un programa que funcione como una cuenta atrás.
14+
*
15+
* - Al iniciarlo tendrás que indicarle el día, mes, año,
16+
* hora, minuto y segundo en el que quieres que finalice.
17+
* - Deberás transformar esa fecha local a UTC.
18+
* - La cuenta atrás comenzará y mostrará los días, horas,
19+
* minutos y segundos que faltan.
20+
* - Se actualizará cada segundo y borrará la terminal en
21+
* cada nueva representación del tiempo restante.
22+
* - Una vez finalice, mostrará un mensaje.
23+
* - Realiza la ejecución, si el lenguaje lo soporta, en
24+
* un hilo independiente.
25+
*/
26+
```
27+
#### Tienes toda la información extendida sobre el roadmap de retos de programación en **[retosdeprogramacion.com/roadmap](https://retosdeprogramacion.com/roadmap)**.
28+
29+
Sigue las **[instrucciones](../../README.md)**, consulta las correcciones y aporta la tuya propia utilizando el lenguaje de programación que quieras.
30+
31+
> Recuerda que cada semana se publica un nuevo ejercicio y se corrige el de la semana anterior en directo desde **[Twitch](https://twitch.tv/mouredev)**. Tienes el horario en la sección "eventos" del servidor de **[Discord](https://discord.gg/mouredev)**.

0 commit comments

Comments
 (0)