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 branch 'main' of https://github.com/Sublian/retos-programacion-…
- Loading branch information
Showing
59 changed files
with
4,095 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/java/Adrian01cst.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,25 @@ | ||
/* | ||
* Escribe un programa que muestre por consola (con un print) los | ||
* números de 1 a 100 (ambos incluidos y con un salto de línea entre | ||
* cada impresión), sustituyendo los siguientes: | ||
* - Múltiplos de 3 por la palabra "fizz". | ||
* - Múltiplos de 5 por la palabra "buzz". | ||
* - Múltiplos de 3 y de 5 a la vez por la palabra "fizzbuzz". | ||
*/ | ||
|
||
public class Adrian01cst { | ||
public static void main(String[] args) { | ||
|
||
for(int i = 1; i <= 100; i++) { | ||
if(i % 3 == 0 && i % 5 ==0) { | ||
System.out.println("fizzbuzz"); | ||
} else if(i % 3 == 0) { | ||
System.out.println("fizz"); | ||
} else if(i % 5 == 0) { | ||
System.out.println("buzz"); | ||
} else { | ||
System.out.println(i); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/kotlin/vicadev.kt
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,38 @@ | ||
fun main() { | ||
print("Introduce un texto: ") | ||
val text = readln().lowercase() | ||
|
||
val leetMap = mapOf( | ||
'a' to "4", | ||
'b' to "|3", | ||
'c' to "[", | ||
'd' to ")", | ||
'e' to "3", | ||
'f' to "|=", | ||
'g' to "&", | ||
'h' to "#", | ||
'i' to "1", | ||
'j' to ",_|", | ||
'k' to ">|", | ||
'l' to "1", | ||
'm' to "/\\/\\", | ||
'n' to "^/", | ||
'o' to "0", | ||
'p' to "|*", | ||
'q' to "(_,)", | ||
'r' to "|2", | ||
's' to "5", | ||
't' to "7", | ||
'u' to "(_)", | ||
'v' to "\\/", | ||
'w' to "\\/\\/", | ||
'x' to "><", | ||
'y' to "j", | ||
'z' to "2", | ||
' ' to " " | ||
) | ||
|
||
var textHacker = "" | ||
text.forEach { note -> textHacker += leetMap[note] } | ||
println(textHacker) | ||
} |
30 changes: 30 additions & 0 deletions
30
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/python/ccaicedo09.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,30 @@ | ||
""" | ||
* Escribe un programa que reciba un texto y transforme lenguaje natural a | ||
* "lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje | ||
* se caracteriza por sustituir caracteres alfanuméricos. | ||
* - Utiliza esta tabla (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/) | ||
* con el alfabeto y los números en "leet". | ||
* (Usa la primera opción de cada transformación. Por ejemplo "4" para la "a") | ||
""" | ||
|
||
def hacker_language(): | ||
|
||
text = input("Ingresa la oración que quieres traducir a lenguaje hacker ---> ").upper() | ||
|
||
leet = {"A": "4", "B": "I3", "C": "[", "D": ")", "E": "3", "F": "|=", "G": "&", "H": "#", "I": "1", | ||
"J": ",_|", "K": ">|", "L": "1", "M": "/\/\\", "N": "^/", "O": "0", "P": "|*", "Q": "(_,)", | ||
"R": "I2", "S": "5", "T": "7", "U": "(_)", "V": "\/", "W": "\/\/", "X": "><", "Y": "j", "Z": "2", | ||
"1": "L", "2": "R", "3": "E", "4": "A", "5": "S", "6": "b", "7": "T", "8": "B", "9": "g", "0": "o"} | ||
|
||
leet_string = "" | ||
|
||
for char in text: | ||
if char in leet.keys(): | ||
leet_string += leet[char] | ||
else: | ||
leet_string += char | ||
|
||
return leet_string | ||
|
||
|
||
print(f"\nTexto traducido ---> {hacker_language()}") |
69 changes: 69 additions & 0 deletions
69
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/python/jarkillo.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,69 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Wed Oct 25 17:23:05 2023 | ||
@author: Jarkillo | ||
""" | ||
''' | ||
* Escribe un programa que reciba un texto y transforme lenguaje natural a | ||
* "lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje | ||
* se caracteriza por sustituir caracteres alfanuméricos. | ||
* - Utiliza esta tabla (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/) | ||
* con el alfabeto y los números en "leet". | ||
* (Usa la primera opción de cada transformación. Por ejemplo "4" para la "a") | ||
''' | ||
|
||
leet_lang = { | ||
|
||
'a': '4', | ||
'b': 'I3', | ||
'c': '[', | ||
'd': ')', | ||
'e': '3', | ||
'f': '|=', | ||
'g': '&', | ||
'h': '#', | ||
'i': '1', | ||
'j': '_|', | ||
'k': '>|', | ||
'l': '1', | ||
'm': '/\/\\', | ||
'n': '^/', | ||
'o': '0', | ||
'p': '|*', | ||
'q': '(_,)', | ||
'r': 'I2', | ||
's': '5', | ||
't': '7', | ||
'u': '(_)', | ||
'v': '\/', | ||
'w': '\/\/', | ||
'x': '><', | ||
'y': 'j', | ||
'z': '2', | ||
'1': 'L', | ||
'2': 'Z', | ||
'3': 'E', | ||
'4': 'A', | ||
'5': 'S', | ||
'6': 'b', | ||
'7': 'T', | ||
'8': 'B', | ||
'9': 'g', | ||
'0': 'o' | ||
} | ||
|
||
|
||
def leet(text): | ||
text = text.lower() | ||
for letra in text: | ||
if letra in leet_lang: | ||
text = text.replace(letra, leet_lang[letra]) | ||
return text | ||
|
||
|
||
print(leet('Hola, me llamo Jarkillo y soy un hacker')) | ||
texto = input(leet('Introduce un texto para transformarlo: ')) | ||
|
||
texto = leet(texto) | ||
print(texto) |
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,14 @@ | ||
""" | ||
* Crea una función que sea capaz de detectar si existe un viernes 13 en el mes y el año indicados. | ||
* - La función recibirá el mes y el año y retornará verdadero o falso. | ||
""" | ||
|
||
from datetime import datetime | ||
|
||
def Friday_13th(month: int, year: int): | ||
date = datetime(year, month, 13) | ||
|
||
return True if date.isoweekday() == 5 else False #.isoweekday() no toma lunes como 0; más cómodo | ||
|
||
print(Friday_13th(9, 2023)) | ||
print(Friday_13th(10, 2023)) |
File renamed without changes.
40 changes: 40 additions & 0 deletions
40
Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/kotlin/vicadev.kt
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,40 @@ | ||
fun main() { | ||
println("-------Partido de Tenis------- \n") | ||
play() | ||
} | ||
|
||
fun points(point: Int): String { | ||
return when(point) { | ||
1 -> "15" | ||
2 -> "30" | ||
3 -> "40" | ||
else -> "Love" | ||
} | ||
} | ||
|
||
fun random(start: Int, end: Int): Int { | ||
require(start <= end) {"No válido"} | ||
return (start..end).random() | ||
} | ||
|
||
fun play() { | ||
var playerOne = 0 | ||
var playerTwo= 0 | ||
|
||
while (playerTwo < 3 && playerOne < 3) { | ||
if (random(1, 2) == 1) playerOne++ | ||
else playerTwo++ | ||
|
||
println("Player 1: ${points(playerOne)} -- Player 2: ${points(playerTwo)}") | ||
|
||
Thread.sleep(1000) | ||
} | ||
|
||
if (playerOne == playerTwo) { | ||
println("Empate") | ||
return | ||
} | ||
if (playerOne > playerTwo) println("\n-----¡¡Ganador Player 1!!-----") | ||
else println("\n-----¡¡Ganador Player 2!!-----") | ||
} | ||
|
81 changes: 81 additions & 0 deletions
81
Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/python/jarkillo.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,81 @@ | ||
''' | ||
/* | ||
* 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. | ||
*/ | ||
''' | ||
|
||
|
||
import os | ||
import random | ||
|
||
|
||
def tenis(secuencia): | ||
|
||
puntuacion = { | ||
'0': 'Love', | ||
'1': '15', | ||
'2': '30', | ||
'3': '40' | ||
} | ||
|
||
p1 = 0 | ||
p2 = 0 | ||
|
||
for punto in secuencia: | ||
|
||
if punto == 'P1': | ||
p1 += 1 | ||
elif punto == 'P2': | ||
p2 += 1 | ||
else: | ||
print('Error en la secuencia') | ||
return | ||
|
||
if p1 == 4 and p2 == 4: | ||
print('Deuce') | ||
empate = True | ||
|
||
if p1 == 4 or p2 == 4: | ||
if empate == False: | ||
print('Ha ganado el P1' if p1 == 4 else 'Ha ganado el P2') | ||
return | ||
else: | ||
print('Ventaja P1' if p1 == 4 else 'Ventaja P2') | ||
p1 -= 1 | ||
p2 -= 1 | ||
return | ||
|
||
else: | ||
print(puntuacion[str(p1)] + ' - ' + puntuacion[str(p2)]) | ||
empate = False | ||
if p1 < 4 and p2 < 4: | ||
print('Fin del tiempo') | ||
print('Ha ganado el P1' if p1 > p2 else 'Ha ganado el P2') | ||
return | ||
|
||
# Metemos secuencias Random | ||
|
||
|
||
secuencia = [] | ||
for i in range(15): | ||
secuencia.append(random.choice(['P1', 'P2'])) | ||
|
||
os.system('PAUSE') | ||
print(secuencia) | ||
os.system('PAUSE') | ||
tenis(secuencia) |
44 changes: 44 additions & 0 deletions
44
Retos/Reto #28 - EXPRESIÓN MATEMÁTICA [Media]/javascript/patriciotrujilllo.js
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,44 @@ | ||
/* | ||
* Crea una función que reciba una expresión matemática (String) | ||
* y compruebe si es correcta. Retornará true o false. | ||
* - Para que una expresión matemática sea correcta debe poseer | ||
* un número, una operación y otro número separados por espacios. | ||
* Tantos números y operaciones como queramos. | ||
* - Números positivos, negativos, enteros o decimales. | ||
* - Operaciones soportadas: + - * / % | ||
* | ||
* Ejemplos: | ||
* "5 + 6 / 7 - 4" -> true | ||
* "5 a 6" -> false | ||
*/ | ||
|
||
const tuplaOperaciones = ['+','-','*','/','%'] | ||
|
||
const expresionMatematica = (expresion) =>{ | ||
const ToArray = expresion.split(' ') | ||
|
||
for(let i=0;i<=ToArray.length-3;i+=2){ | ||
|
||
if(ToArray.length<3) return false | ||
|
||
if(isNaN(Number(ToArray[i]))){ | ||
return false | ||
} | ||
if(!tuplaOperaciones.includes(ToArray[i+1])){ | ||
return false | ||
} | ||
if(isNaN(Number(ToArray[i+2]))){ | ||
return false | ||
} | ||
return true | ||
} | ||
} | ||
|
||
console.log(expresionMatematica("5 + 6 / 7 - 4"))//---->true | ||
console.log(expresionMatematica("5 * 6 / 7 + 4"))//---->true | ||
console.log(expresionMatematica("5 * 6 / -7 + 4 % 3"))//---->true | ||
console.log(expresionMatematica("-5 * 6 / 7 + 4 % 3"))//---->true | ||
console.log(expresionMatematica("5 a 6")) //---->false | ||
console.log(expresionMatematica("a * 6")) //---->false | ||
console.log(expresionMatematica("5 x 6")) //---->false | ||
console.log(expresionMatematica("5 * b")) //---->false |
20 changes: 20 additions & 0 deletions
20
Retos/Reto #29 - EL CARÁCTER INFILTRADO [Fácil]/python/PushoDev.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 @@ | ||
def encontrar_caracter_infiltrado(cad1, cad2): | ||
infiltrados = [] | ||
if len(cad1) != len(cad2): | ||
return infiltrados # Retorna una lista vacía si las cadenas no tienen la misma longitud | ||
for i in range(len(cad1)): | ||
if cad1[i] != cad2[i]: | ||
infiltrados.append(cad1[i]) | ||
return infiltrados | ||
|
||
print("Pusho.Dev") | ||
print("https://puschoft.blogspot.com") | ||
|
||
# Solicitar al usuario ingresar textos para identificar | ||
cad1 = input("Ingrese la primera cadena: ") | ||
cad2 = input("Ingrese la segunda cadena: ") | ||
|
||
# Mostrar los Resultados de este ejercicio | ||
resp = encontrar_caracter_infiltrado(cad1, cad2) | ||
print("Los caracteres infiltrados son:", resp) | ||
print("Muchas Gracias por participar ...") |
File renamed without changes.
Oops, something went wrong.