-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/kotlin/mouredev.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,28 @@ | ||
|
||
fun main() { | ||
println(leetTranslator("Leet")) | ||
println(leetTranslator("Aquí está un texto de prueba para ver si funciona el reto!")) | ||
} | ||
|
||
private fun leetTranslator(text: String): String { | ||
|
||
val leet = mapOf("A" to "4", "B" to "I3", "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 "I2", "S" to "5", "T" to "7", | ||
"U" to "(_)", "V" to "\\/", "W" to "\\/\\/", "X" to "><", "Y" to "j", "Z" to "2", | ||
"1" to "L", "2" to "R", "3" to "E", "4" to "A", "5" to "S", "6" to "b", "7" to "T", | ||
"8" to "B", "9" to "g", "0" to "o") | ||
|
||
var leetText = "" | ||
|
||
for (word in text) { | ||
val character = word.toString().uppercase() | ||
leetText += if (leet.containsKey(character)) { | ||
leet[character] | ||
} else { | ||
word.toString() | ||
} | ||
} | ||
|
||
return leetText | ||
} |
21 changes: 21 additions & 0 deletions
21
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/python/mouredev.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,21 @@ | ||
def leet_translator(text): | ||
|
||
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_text = "" | ||
|
||
for word in text: | ||
if word.upper() in leet.keys(): | ||
leet_text += leet[word.upper()] | ||
else: | ||
leet_text += word | ||
|
||
return leet_text | ||
|
||
|
||
print(leet_translator("Leet")) | ||
print(leet_translator("Aquí está un texto de prueba para ver si funciona el reto!")) | ||
print(leet_translator(input("Texto a traducir: "))) |
17 changes: 17 additions & 0 deletions
17
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/swift/mouredev.swift
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,17 @@ | ||
import Foundation | ||
|
||
func leetTranslator(text: String) -> String { | ||
|
||
let 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"] | ||
|
||
var leetText = "" | ||
|
||
for word in text { | ||
leetText += leet[word.description.uppercased()] ?? word.description | ||
} | ||
|
||
return leetText | ||
} | ||
|
||
print(leetTranslator(text: "Leet")) | ||
print(leetTranslator(text: "Aquí está un texto de prueba para ver si funciona el reto!")) |
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 @@ | ||
# Reto #2: EL PARTIDO DE TENIS | ||
#### Dificultad: Media | Publicación: 09/01/23 | Corrección: 16/01/23 | ||
|
||
## Enunciado | ||
|
||
``` | ||
/* | ||
* 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. | ||
*/ | ||
``` | ||
#### Tienes toda la información extendida sobre los retos de programación semanales en **[retosdeprogramacion.com/semanales2023](https://retosdeprogramacion.com/semanales2023)**. | ||
|
||
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)**. |
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,39 @@ | ||
# Script para calcular el % de uso de cada lenguaje | ||
|
||
import os | ||
import operator | ||
|
||
|
||
def scan_dir(dir_path, languages={}, total=0, path_name=None) -> tuple: | ||
for path in os.scandir(dir_path): | ||
if path.is_dir(): | ||
if "Reto #" not in path.name and path.name not in languages: | ||
languages[path.name] = 0 | ||
|
||
_, total = scan_dir(path.path, languages, total, path.name) | ||
else: | ||
if path_name in languages: | ||
total += 1 | ||
languages[path_name] += 1 | ||
|
||
return (languages, total) | ||
|
||
|
||
# Directorio de retos a analizar | ||
dir_path = os.path.dirname(__file__) | ||
print(dir_path) | ||
# Directorio de un reto específico | ||
# dir_path += "/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]" | ||
|
||
# Función recursiva para recorrer el directorio y almacenar el número de archivos por lenguajes | ||
languajes, total = scan_dir(dir_path) | ||
|
||
# Ordenación por uso | ||
languajes = dict( | ||
sorted(languajes.items(), key=operator.itemgetter(1), reverse=True)) | ||
|
||
# Estadísticas | ||
print(f"{len(languajes.keys())} Lenguajes ({total} correcciones):") | ||
for languaje in languajes: | ||
print( | ||
f"> {languaje.upper()} ({languajes[languaje]}): {round(languajes[languaje] / total * 100, 2)}%") |