forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mouredev/main
Pull
- Loading branch information
Showing
10 changed files
with
588 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/java/IASR1987.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package reto_00_FIZZBUZZ; | ||
|
||
public class IASR1987 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
for(int i=1; i<=100;i++) { | ||
if(i%3==0) { | ||
if(i%5==0) { | ||
System.out.println("FIZZBUZZ"); | ||
}else { | ||
System.out.println("FIZZ"); | ||
} | ||
}else if(i%5==0) { | ||
System.out.println("BUZZ"); | ||
}else { | ||
System.out.println(i); | ||
} | ||
} | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/python/luisramos98.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python3 | ||
|
||
for i in range(1,101): | ||
if((i%3) == 0 and (i%5) == 0): | ||
print(f"{i} - fizzbuzz") | ||
|
||
elif((i%3) == 0): | ||
print(f"{i} - fizz") | ||
|
||
elif((i%5 == 0)): | ||
print(f"{i} - buzz") | ||
|
34 changes: 34 additions & 0 deletions
34
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/java/IASR1987.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package reto_01_LenguajeHacker; | ||
|
||
import java.util.Scanner; | ||
|
||
public class IASR1987 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
Scanner teclado = new Scanner(System.in); | ||
|
||
char lista[] = {' ','a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', | ||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', | ||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; | ||
String leet[] = {" ","4", "l3", "[", ")", "3",".=","&&","-","1",",.","-","1","/A./", | ||
"-/","0","-*","(a,)","l2","5","7","(o)","-/","-/","-","j","2", | ||
"o","L","R","E","A","S","b","T","B","g"}; | ||
System.out.println("Introduce una frase para traducirla a lenguaje"); | ||
String frase= teclado.nextLine(); | ||
|
||
boolean letraEncontrada; | ||
|
||
for(int i=0; i<frase.length();i++) { | ||
letraEncontrada=false; | ||
for(int j=0; j<=lista.length && letraEncontrada==false;j++) { | ||
if(frase.charAt(i)==lista[j]) { | ||
letraEncontrada=true; | ||
System.out.print(leet[j]); | ||
}; | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/python/luisramos98.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python3 | ||
|
||
diccionario = {'.':'.', ',':',', ' ':' ', 'ñ':'^/~', 'a':'4', 'b':'|3', 'c':'[', 'd':')', 'e':'3', 'f':'|=', 'g':'&', 'h':'#', 'i':'1', 'j':',_|', 'k':'>|', 'l':'|_', 'm':'JVI', 'n':'^/', 'o':'0', 'p':'|*', 'q':'(_,)', 'r':'|2', 's':'5', 't':'7', 'u':'v', 'v':'\/', 'w':'\/\/', 'x':'><', 'y':'j', 'z':'2'} | ||
|
||
palabra = input('Ingresa una frase sin tilde: ') | ||
|
||
palabra_low = palabra.lower() | ||
|
||
|
||
leet_code='' | ||
|
||
for char in palabra_low: | ||
|
||
for key, valor in diccionario.items(): | ||
|
||
if(char == key): | ||
leet_code+=valor | ||
break | ||
|
||
print(leet_code) |
64 changes: 64 additions & 0 deletions
64
Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/java/IASR1987.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Escribe un programa que muestre cómo transcurre un juego de tenis y quién lo ha ganado. | ||
* El programa recibirá una secuencia formada por "P1" (Player 1) o "P2" (Player 2), según quien | ||
* gane cada punto del juego. | ||
* | ||
* - Las puntuaciones de un juego son "Love" (cero), 15, 30, 40, "Deuce" (empate), ventaja. | ||
* - Ante la secuencia [P1, P1, P2, P2, P1, P2, P1, P1], el programa mostraría lo siguiente: | ||
* 15 - Love | ||
* 30 - Love | ||
* 30 - 15 | ||
* 30 - 30 | ||
* 40 - 30 | ||
* Deuce | ||
* Ventaja P1 | ||
* Ha ganado el P1 | ||
* - Si quieres, puedes controlar errores en la entrada de datos. | ||
* - Consulta las reglas del juego si tienes dudas sobre el sistema de puntos. | ||
*/ | ||
package reto_02_ElPartidoDeTenis; | ||
|
||
public class IASR1987 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
int P1=0; | ||
int P2=0; | ||
String[] secuencia= {"P1","P1","P1","P2","P2","P2","P1","P2","P2","P1","P1","P1"}; | ||
String[] puntuacion= {"love","15","30","40","Deuce","Ventaja","Ganaste"}; | ||
boolean ganador= false; | ||
|
||
for(int i=0;ganador==false;i++) { | ||
|
||
if(secuencia[i].equals("P1")) { | ||
P1++; | ||
}else { | ||
P2++; | ||
} | ||
|
||
if(P1<4 && P2<4) { | ||
System.out.println(puntuacion[P1]+"--"+puntuacion[P2]); | ||
}else if(P1>=4 || P2>=4){ | ||
if(P1>=(P2+2)) { | ||
System.out.println("Ganador Jugador 1"); | ||
ganador=true; | ||
}else if(P2>=(P1+2)) { | ||
System.out.println("Ganador Jugador 2"); | ||
ganador=true; | ||
}else if(P1==P2) { | ||
System.out.println("Deuce"); | ||
}else { | ||
if(P1>P2) { | ||
System.out.println("Ventaja jugador 1"); | ||
}else { | ||
System.out.println("Ventaja Jugador 2"); | ||
} | ||
} | ||
} | ||
|
||
System.out.println("Puntuacion 1 = " + P1 + " Puntuacion 2 = "+ P2); | ||
|
||
} | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/python/luisramos98.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python3 | ||
|
||
#secuencia = ['P1', 'P1', 'P2', 'P2', 'P1', 'P2', 'P1', 'P1'] | ||
#secuencia = ['P2', 'P2', 'P1', 'P1', 'P2', 'P1', 'P2', 'P2'] | ||
#secuencia = ['P2', 'P2', 'P1', 'P1', 'P2', 'P1', 'P2', 'P1','P2','P1','P2','P2'] | ||
|
||
secuencia = [] | ||
puntuaciones = ['Love','15','30','40'] | ||
resultados = [] | ||
end_game = False | ||
|
||
p1_historial = ['Love'] | ||
p2_historial = ['Love'] | ||
|
||
p1_points = 0 | ||
p2_points = 0 | ||
|
||
while end_game == False: | ||
play = input('Ingrese un P1 si es player 1 y un P2 si es un player 2: ') | ||
|
||
if play == 'P1': | ||
p1_points += 1 | ||
if p1_points > 3: | ||
if p2_historial[-1] == '40' and p1_historial[-1] == '40': | ||
p1_historial.append('Deuce') | ||
if p1_historial[-1] == 'Ventaja P1' and abs(p1_points - p2_points) == 2: | ||
p1_historial.append('Ha Ganado P1') | ||
#resultados.append(p1_historial[-1]) | ||
end_game = True | ||
elif p2_historial[-1] == 'Ventaja P2': | ||
p2_historial.append('Deuce') | ||
p1_historial.append('Deuce') | ||
elif p1_historial[-1] == 'Deuce': | ||
p1_historial.append('Ventaja P1') | ||
else: | ||
p1_historial.append(puntuaciones[p1_points]) | ||
else: | ||
p2_points += 1 | ||
|
||
if p2_points > 3: | ||
if p2_historial[-1] == '40' and p1_historial[-1] == '40': | ||
p2_historial.append('Deuce') | ||
if p2_historial[-1] == 'Ventaja P2' and abs(p1_points - p2_points) == 2: | ||
p2_historial.append('Ha Ganado P2') | ||
#resultados.append(p2_historial[-1]) | ||
end_game = True | ||
elif p1_historial[-1] == 'Ventaja P1': | ||
p2_historial.append('Deuce') | ||
p1_historial.append('Deuce') | ||
elif p2_historial[-1] == 'Deuce': | ||
p2_historial.append('Ventaja P2') | ||
|
||
else: | ||
p2_historial.append(puntuaciones[p2_points]) | ||
|
||
if p1_historial[-1] == '40' and p2_historial[-1] == '40' or p1_historial[-1] == 'Deuce' and p2_historial[-1] == 'Deuce': | ||
#print(f'Deuce') | ||
resultados.append('Deuce') | ||
elif p1_historial[-1] == 'Ventaja P1': | ||
#print(p1_historial[-1]) | ||
resultados.append(p1_historial[-1]) | ||
elif p1_historial[-1] == 'Ha Ganado P1': | ||
#print(p1_historial[-1]) | ||
resultados.append(p1_historial[-1]) | ||
elif p2_historial[-1] == 'Ventaja P2': | ||
#print(p2_historial[-1]) | ||
resultados.append(p2_historial[-1]) | ||
elif p2_historial[-1] == 'Ha Ganado P2': | ||
#print(p2_historial[-1]) | ||
resultados.append(p2_historial[-1]) | ||
else: | ||
#print(f'{p1_historial[-1]} - {p2_historial[-1]}') | ||
resultados.append(f'{p1_historial[-1]} - {p2_historial[-1]}') | ||
|
||
|
||
|
||
for resultado in resultados: | ||
print(resultado) | ||
|
||
|
||
|
||
|
65 changes: 65 additions & 0 deletions
65
Retos/Reto #3 - EL GENERADOR DE CONTRASEÑAS [Media]/python/luisramos98.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
/* | ||
* Escribe un programa que sea capaz de generar contraseñas de forma aleatoria. | ||
* Podrás configurar generar contraseñas con los siguientes parámetros: | ||
* - Longitud: Entre 8 y 16. | ||
* - Con o sin letras mayúsculas. | ||
* - Con o sin números. | ||
* - Con o sin símbolos. | ||
* (Pudiendo combinar todos estos parámetros entre ellos) | ||
*/ | ||
''' | ||
import random | ||
|
||
limit_sup = 0 | ||
limit_inf = 0 | ||
|
||
in_range = False | ||
longitud = 0 | ||
|
||
is_mayusculas = False | ||
is_numeros = False | ||
is_simbolos = False | ||
|
||
mayusculas = [chr(i) for i in range(65, 91)] | ||
minusculas = [chr(i) for i in range(97, 123)] | ||
numeros = [chr(i) for i in range(48, 58)] | ||
simbolos = [chr(i) for i in range(33, 48)] + [chr(i) for i in range(58, 64)] + [chr(i) for i in range(91, 97)] + [chr(i) for i in range(123, 127)] | ||
|
||
contraseña = '' | ||
|
||
while in_range == False: | ||
longitud = int(input("\n[i] Ingrese la longitud que desea para su contraseña el valor tiene que estár entre 8 y 16 caracteres: ")) | ||
|
||
in_range = True if not ( longitud < 8 or longitud > 16 ) else False | ||
|
||
if not in_range: | ||
print('\n\t[!] Solo se acepta una cantidad de 8 hasta 16 caracteres en la contraseña') | ||
|
||
is_mayusculas = False if input("\n\t[i] Desea MAYÚSCULAS en su password (Si/No): ").lower() != 'si' else True | ||
is_numeros = False if input("\n\t[i] Desea NÚMEROS en su password (Si/No): ").lower() != 'si' else True | ||
is_simbolos = False if input("\n\t[i] Desea SÍMBOLOS en su password (Si/No): ").lower() != 'si' else True | ||
|
||
|
||
i = 0 | ||
caracteres = minusculas.copy() | ||
caracteres += mayusculas if is_mayusculas else [] | ||
caracteres += numeros if is_numeros else [] | ||
caracteres += simbolos if is_simbolos else [] | ||
|
||
while i < longitud: | ||
|
||
limit_sup = len(caracteres) - 1 | ||
limit_inf = 0 | ||
|
||
contraseña += caracteres[random.randint(limit_inf,limit_sup)] | ||
i += 1 | ||
|
||
|
||
|
||
print(f'\n[+] Se ha generado la siguiente contraseña: {contraseña}') | ||
|
||
|
||
|
42 changes: 42 additions & 0 deletions
42
Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/python/luisramos98.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
/* | ||
* Escribe un programa que, dado un número, compruebe y muestre si es primo, fibonacci y par. | ||
* Ejemplos: | ||
* - Con el número 2, nos dirá: "2 es primo, fibonacci y es par" | ||
* - Con el número 7, nos dirá: "7 es primo, no es fibonacci y es impar" | ||
*/ | ||
''' | ||
import math | ||
|
||
numero = int(input("\n[i] Ingrese un número para comprobar si es primo, fibonacci o par: ")) | ||
|
||
es_primo = all((numero % i) != 0 for i in range(2, int(numero ** 0.5) + 1)) | ||
|
||
es_par = True if (numero % 2) == 0 else False | ||
|
||
es_cuadrado_perfecto = lambda n: True if (int(math.sqrt(n)) * int(math.sqrt(n))) == n else False | ||
es_fibonacci = True if es_cuadrado_perfecto(5 * numero * numero + 4) or es_cuadrado_perfecto(5 * numero * numero - 4) else False | ||
|
||
resultados = [] | ||
|
||
resultados.append('primo' if es_primo else 'no es primo') | ||
resultados.append('par' if es_par else 'impar') | ||
resultados.append('fibonacci' if es_fibonacci else 'no es fibonacci') | ||
|
||
respuesta = f'\n[+] {numero} es ' | ||
|
||
for resultado in resultados: | ||
|
||
if resultados[-1] == resultado: | ||
respuesta += f'y {resultado}.' | ||
break | ||
else: | ||
respuesta += f'{resultado}, ' | ||
|
||
|
||
print(respuesta) | ||
|
||
|
||
|
Oops, something went wrong.