Skip to content

Commit

Permalink
Corrección Roadmap 39 + Nuevo ejercicio 40
Browse files Browse the repository at this point in the history
  • Loading branch information
mouredev committed Sep 30, 2024
1 parent 3908e2b commit d2cf779
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
|36|[EL SOMBRERO SELECCIONADOR](./Roadmap/36%20-%20EL%20SOMBRERO%20SELECCIONADOR/ejercicio.md)|[📝](./Roadmap/36%20-%20EL%20SOMBRERO%20SELECCIONADOR/python/mouredev.py)|[▶️](https://youtu.be/_UjOD587elY)|[👥](./Roadmap/36%20-%20EL%20SOMBRERO%20SELECCIONADOR/)
|37|[OASIS VS LINKIN PARK](./Roadmap/37%20-%20OASIS%20VS%20LINKIN%20PARK/ejercicio.md)|[📝](./Roadmap/37%20-%20OASIS%20VS%20LINKIN%20PARK/python/mouredev.py)|[▶️](https://youtu.be/q-zBKriHupY)|[👥](./Roadmap/37%20-%20OASIS%20VS%20LINKIN%20PARK/)
|38|[MOUREDEV PRO](./Roadmap/38%20-%20MOUREDEV%20PRO/ejercicio.md)|[📝](./Roadmap/38%20-%20MOUREDEV%20PRO/python/mouredev.py)|[▶️](https://youtu.be/AbGROLoAVLs)|[👥](./Roadmap/38%20-%20MOUREDEV%20PRO/)
|39|[BATMAN DAY](./Roadmap/39%20-%20BATMAN%20DAY/ejercicio.md)|[🗓️ 30/09/24](https://discord.gg/Ak6SdZZ8?event=1285336208586833930)||[👥](./Roadmap/39%20-%20BATMAN%20DAY/)
|39|[BATMAN DAY](./Roadmap/39%20-%20BATMAN%20DAY/ejercicio.md)|[📝](./Roadmap/39%20-%20BATMAN%20DAY/python/mouredev.py)||[👥](./Roadmap/39%20-%20BATMAN%20DAY/)
|40|[FORTNITE RUBIUS CUP](./Roadmap/40%20-%20FORTNITE%20RUBIUS%20CUP/ejercicio.md)|[🗓️ 07/10/24](https://discord.gg/u3R4HUUE?event=1287881476460773456)||[👥](./Roadmap/40%20-%20FORTNITE%20RUBIUS%20CUP/)

## Cursos en YouTube

Expand Down
80 changes: 80 additions & 0 deletions Roadmap/39 - BATMAN DAY/python/mouredev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from datetime import datetime, timedelta

# Reto 1

year_of_creation = 1939
anniversary_year = year_of_creation + 85

batman_day_anniversary_dates = []

while anniversary_year <= year_of_creation + 100:

september = datetime(anniversary_year, 9, 1)

first_saturday = 5 - september.weekday() if september.weekday() <= 5 else 12 - \
september.weekday()

third_saturday = september + timedelta(days=first_saturday + 14)

batman_day_anniversary_dates.append(
(
anniversary_year,
anniversary_year - year_of_creation,
third_saturday.strftime("%d-%m-%Y")
)
)

anniversary_year += 1

for year, anniversary, batman_day in batman_day_anniversary_dates:
print(f"Batman day {year} ({anniversary} aniversario): {batman_day}")

# Reto 2


def sum_subgrid_alerts(sensors, center_x, center_y) -> int:

total = 0

for x in range(center_x - 1, center_x + 2):
for y in range(center_y - 1, center_y + 2):
for sensor in sensors:
if sensor[0] == x and sensor[1] == y:
total += sensor[2]

return total


def batcave_security_system(sensors):

max_alert_level = 0
max_alert_coordinate = (0, 0)

for x in range(1, 19):
for y in range(1, 19):
alert_level = sum_subgrid_alerts(sensors, x, y)
if alert_level > max_alert_level:
max_alert_level = alert_level
max_alert_coordinate = (x, y)

distance = abs(max_alert_coordinate[0]) + abs(max_alert_coordinate[1])
activate_protocol = max_alert_level > 20

return max_alert_coordinate, max_alert_level, distance, activate_protocol


sensors = [
(2, 3, 7),
(4, 3, 8),
(2, 2, 7),
(10, 12, 8),
(11, 11, 8),
(10, 11, 8),
(15, 18, 4)
]

result = batcave_security_system(sensors)
print(f"Centro cuadrícula más amenazada: {result[0]}.")
print(f"Máximo nivel de alerta: {result[1]}.")
print(f"Distancia a la Batcueva: {result[2]}.")
print(f"Activar protocolo de seguridad: {"Sí" if result[3] else "No"}.")
27 changes: 27 additions & 0 deletions Roadmap/40 - FORTNITE RUBIUS CUP/ejercicio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# #40 FORTNITE RUBIUS CUP
> #### Dificultad: Media | Publicación: 30/09/24 | Corrección: 07/10/24
## Ejercicio

```
/*
* EJERCICIO:
* ¡Rubius tiene su propia skin en Fortnite!
* Y va a organizar una competición para celebrarlo.
* Esta es la lista de participantes:
* https://x.com/Rubiu5/status/1840161450154692876
*
* Desarrolla un programa que obtenga el número de seguidores en
* Twitch de cada participante, la fecha de creación de la cuenta
* y ordene los resultados en dos listados.
* - Usa el API de Twitch: https://dev.twitch.tv/docs/api/reference
* (NO subas las credenciales de autenticación)
* - Crea un ranking por número de seguidores y por antigüedad.
* - Si algún participante no tiene usuario en Twitch, debe reflejarlo.
*/
```
#### Tienes toda la información extendida sobre el roadmap de retos de programación en **[retosdeprogramacion.com/roadmap](https://retosdeprogramacion.com/roadmap)**.

Sigue las **[instrucciones](../../README.md)**, consulta las correcciones y aporta la tuya propia utilizando el lenguaje de programación que quieras.

> 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 comments on commit d2cf779

Please sign in to comment.