Skip to content
Open
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 ejerciciosRandom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def solucionarRompecabezas(N):
# Definimos un módulo grande para manejar el cálculo
MOD = 10**10 # Últimos 10 dígitos

var_A = 1
var_B = 1
var_C = 1
var_D = 1

for _ in range(1, N+1):
# Realizamos todos los cálculos con módulo para evitar desbordamiento
resultado = (3 * var_D + var_C + 4 * var_B + var_A) % MOD
var_A = var_B
var_B = var_C
var_C = var_D
var_D = resultado

return var_D

# Pruebas
print("solucionarRompecabezas(10):", solucionarRompecabezas(10))
print("solucionarRompecabezas(100):", solucionarRompecabezas(100))

# Cálculo para 2023^100
N = pow(2023, 100)
print("solucionarRompecabezas(2023^100):", solucionarRompecabezas(N))
104 changes: 104 additions & 0 deletions exercise_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
print("EXERCISE 1")

class Jugador:
def __init__(self, nombre, goles, velocidad, asistencias, precision_pase, involucramientos_defensivos, numero_camiseta):
self.nombre = nombre
self.goles = goles
self.velocidad = velocidad
self.asistencias = asistencias
self.precision_pase = precision_pase
self.involucramientos_defensivos = involucramientos_defensivos
self.numero_camiseta = numero_camiseta

jugadores = [
Jugador("Bruno Fernandes", 5, 6, 9, 10, 3, 8),
Jugador("Rasmus Hojlund", 12, 8, 2, 6, 2, 11),
Jugador("Harry Maguire", 1, 5, 1, 7, 9, 5),
Jugador("Alejandro Garnacho", 8, 7, 8, 6, 0, 17),
Jugador("Mason Mount", 2, 6, 4, 8, 1, 7)
]

def mostrar_menu():
print("\nMenú Principal:")
print("1. Revisar Jugador")
print("2. Comparar dos Jugadores")
print("3. Identificar al Jugador más Rápido")
print("4. Identificar al Máximo Goleador")
print("5. Identificar al Jugador con más Asistencias")
print("6. Identificar al Jugador con Mayor Precisión de Pase")
print("7. Identificar al Jugador con más Involucramientos Defensivos")
print("8. Salir")

def revisar_jugador(numero_camiseta):
for jugador in jugadores:
if jugador.numero_camiseta == numero_camiseta:
print("\nDetalles de", jugador.nombre)
print("Goles:", jugador.goles)
print("Velocidad:", jugador.velocidad)
print("Asistencias:", jugador.asistencias)
print("Precisión de Pase:", jugador.precision_pase)
print("Involucramientos Defensivos:", jugador.involucramientos_defensivos)
return
print("Número de camiseta no encontrado.")

def comparar_jugadores(num_camiseta1, num_camiseta2):
jugador1 = None
jugador2 = None

for jugador in jugadores:
if jugador.numero_camiseta == num_camiseta1:
jugador1 = jugador
elif jugador.numero_camiseta == num_camiseta2:
jugador2 = jugador

if jugador1 and jugador2:
print("\nComparación entre", jugador1.nombre, "y", jugador2.nombre)
print("Goles:", jugador1.goles, "vs", jugador2.goles)
print("Velocidad:", jugador1.velocidad, "vs", jugador2.velocidad)
print("Asistencias:", jugador1.asistencias, "vs", jugador2.asistencias)
print("Precisión de Pase:", jugador1.precision_pase, "vs", jugador2.precision_pase)
print("Involucramientos Defensivos:", jugador1.involucramientos_defensivos, "vs", jugador2.involucramientos_defensivos)
else:
print("Número de camiseta no encontrado.")

def identificar_maximo(atributo):
max_valor = -1
max_jugador = None

for jugador in jugadores:
valor = getattr(jugador, atributo)
if valor > max_valor:
max_valor = valor
max_jugador = jugador

print("\nJugador con", atributo.capitalize(), "más alto:", max_jugador.nombre, "(", max_valor, "puntos)")

while True:
mostrar_menu()
opcion = input("\nSeleccione una opción (1-8): ")

if opcion == '1':
num_camiseta = int(input("\nIngrese el número de camiseta del jugador: "))
revisar_jugador(num_camiseta)
elif opcion == '2':
num_camiseta1 = int(input("\nIngrese el número de camiseta del primer jugador: "))
num_camiseta2 = int(input("Ingrese el número de camiseta del segundo jugador: "))
comparar_jugadores(num_camiseta1, num_camiseta2)
elif opcion == '3':
identificar_maximo('velocidad')
elif opcion == '4':
identificar_maximo('goles')
elif opcion == '5':
identificar_maximo('asistencias')
elif opcion == '6':
identificar_maximo('precision_pase')
elif opcion == '7':
identificar_maximo('involucramientos_defensivos')
elif opcion == '8':
print("\n¡Hasta luego!")
break
else:
print("\nOpción no válida. Por favor, seleccione una opción del 1 al 8.")


"""con esto se termina el numero 1"""
73 changes: 73 additions & 0 deletions exercise_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""2. A travel agency has a special offer for traveling in any season of 2024. Their destinations are:

Winter: Andorra and Switzerland. In Andorra, there are skiing activities, and in Switzerland, there's a tour of the Swiss Alps.
Summer: Spain and Portugal. In Spain, there are hiking and extreme sports activities. In Portugal,
there are activities on the beaches.
Spring: France and Italy. In France, there are extreme sports activities, and in Italy,
there's a cultural and historical tour.
Autumn: Belgium and Austria. In Belgium, there are hiking and extreme sports activities, and in Austria,
there are cultural and historical activities.
Note: Traveling in winter costs $100, in autumn $200, in spring $300, and in summer $400.

Design a system that helps users choose their best destination according to their personal preferences and the season they want to travel in.
12. Important: With the information you have, you should ask the user the right questions and display on screen what their best destination would be.

Clue: You could consider the user's budget"""

while True:
print("Travel season 2024")
print()
print("system that helps users choose their best destination according to their personal preferences and the season they want to travel in")
print("ok do you want continues?")
answer = input("yes or not?: ")
if answer == "yes":
print("okay")
else:
print("good bye")
exit()
print()
print("first tell us how much is your budget")
budget = int(input("Insert your budget for this travel: ")) #int
print()
print("okay now when you travel?")
date = (input("season of your travel: ")) #string
print()
print("and finally what activities you prefer?")
activities = input("What activity would you like to do on your trip? Sport activities or cultural activities: ") #string
print()
print(f"okay your budget is {budget} and you travel on the {date},the activited you selected are {activities}")

if date == "winter" and activities == "sport activities":
print(f"i recomend you a trip to Andorra, for this trip the cost will by $100 and your budget is {budget}.")
continue
elif date == "winter" and activities == "cultural activities":
print(f"i recomend you a trip to Switzerland, for this trip the cost will by $100 and your budget is {budget}")
continue
elif date == "summer" and activities == "sport activities":
print(f"i recomend you a trip to Spain, for this trip the cost will by $400 and your budget is {budget}")
continue
elif date == "summer" and activities == "cultural activities":
print(f"i recomend you a trip to Portugal, for this trip the cost will by $400 and your budget is {budget}")
continue
elif date == "spring" and activities == "sport activities":
print(f"i recomend you a trip to France, for this trip the cost will by $300 and your budget is {budget}")
continue
elif date == "spring" and activities == "cultural activities":
print(f"i recomend you a trip to Italy, for this trip the cost will by $300 and your budget is {budget}")
continue
elif date == "autumn" and activities == "sport activities":
print(f"i recomend you a trip to Belgium, for this trip the cost will by $200 and your budget is {budget}")
continue
elif date == "autumn" and activities == "cultural activities":
print(f"i recomend you a trip to Austria, for this trip the cost will by $200 and your budget is {budget}")
continue
else:
print("incorrect data")
break







81 changes: 81 additions & 0 deletions exercise_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""3.

The Valencia Hospital is developing an application to manage appointments. Design an algorithm for this application with the following features:

It must have a login and validate the data; after the third failed attempt, it should be locked.
The user can schedule an appointment for: General Medicine, Emergency Care, Clinical Analysis, Cardiology, Neurology, Nutrition, Physiotherapy, Traumatology, and Internal Medicine.
There are 3 doctors for each specialty.
The user can only book one appointment per specialist. An error message should be displayed if the user tries to choose two appointments with the same doctor or the same specialty. As a developer, you can choose the doctors' names.
The maximum limit for appointments, in general, is 3.
Upon selecting a specialty, it will display if the user prefers a morning or afternoon appointment and show available hours. As a developer, you can choose the hours.
Display available specialists.
The user can choose their preferred specialist.
The basic process is: Login -> Choose specialty -> Choose doctor -> Choose time slot."""

import datetime

# Hacemos una clase Hospital la cual va tener toda la informacion para validar y acceder a la misma con sus respectivos setter y getter

class Hospital:
def __init__(self):
self.usuario = {"Lucas":12345,"Martin":1234,"Keila":123}
self.doctor = {"General Medicine":["juan","lucas","Gallo"],"Emergency Care":["jehova","david","jonathan"],"Clinical Analysis":["Lula","Milei","Trump"],"Cardiology":["marcos","facundo","Roberto"],"Neurology":["kian","Osiris","Liana"],"Nutrition":["Clarita","bulma","Kiara"],"Physiotherapy":["Sofia","Sabrina","delfina"],"Traumatology":["juana","Riana","Artemisa"],"Internal Medicine":["Raul","Lucio","Ambesa"]}
self.category = ["General Medicine", "Emergency Care", "Clinical Analysis", "Cardiology", "Neurology", "Nutrition", "Physiotherapy", "Traumatology", "Internal Medicine"]
self.appointments = {} # se agregaran las citas como datetime:[doctor,especialidad,usuario]


def validate_pass(self, usuario, password):
"""Función que valida las contraseñas ingresadas"""
if usuario not in self.usuario:
raise ValueError("Usuario inválido")
if self.usuario[usuario] != password:
raise ValueError("Contraseña incorrecta")
return True # Si el usuario y la contraseña son correctos

def validate_doctor(self, doctor, date_time):
"""Función que valida si un doctor está disponible en una fecha y hora"""
if date_time in self.appointments:
# Verificamos si el doctor ya tiene una cita programada en esa fecha
for appointment in self.appointments[date_time]:
if appointment[0] == doctor:
raise ValueError(f"El doctor {doctor} ya tiene una cita a esta hora.")
else:
self.appointments[date_time] = [] # Crear una nueva lista de citas en esa hora

return True

def make_appointment(self, usuario, doctor, category, date_time):
"""Función que permite al usuario hacer una cita"""
if self.validate_doctor(doctor, date_time): # Valida si el doctor está disponible
self.appointments[date_time].append([doctor, category, usuario])
print(f"Cita confirmada con {doctor} para la categoría {category} a las {date_time}")
else:
print("El doctor no está disponible en este horario.")



####################################### Aplicacion Principal #######################################

hospital = Hospital()

# Primero validamos un usuario
try:
hospital.validate_pass("Lucas", 12345)
print("Usuario validado correctamente")
except ValueError as e:
print(f"Error: {e}")

# Luego hacemos una cita
try:
# Hacemos una cita para el doctor "juan" en "General Medicine" a las 2024-12-03 10:00
date_time = datetime.datetime(2024, 12, 3, 10, 0)
hospital.make_appointment("Lucas", "juan", "General Medicine", date_time)
except ValueError as e:
print(f"Error: {e}")

# Intentamos hacer otra cita para el mismo doctor a la misma hora
try:
hospital.make_appointment("Martin", "juan", "Emergency Care", date_time)
except ValueError as e:
print(f"Error: {e}")