From cc0e8188890a8ab020c074ea24fd09ba080917d1 Mon Sep 17 00:00:00 2001 From: Carlos A Date: Fri, 28 Jul 2023 00:07:49 -0500 Subject: [PATCH 1/6] reto #30 - JavaScript --- .../javascript/test0n3.js | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/test0n3.js diff --git a/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/test0n3.js b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/test0n3.js new file mode 100644 index 0000000000..fbc8546ebe --- /dev/null +++ b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/test0n3.js @@ -0,0 +1,61 @@ +// +// Los primeros dispositivos móviles tenían un teclado llamado T9 +// con el que se podía escribir texto utilizando únicamente su +// teclado numérico (del 0 al 9). +// +// Crea una función que transforme las pulsaciones del T9 a su +// representación con letras. +// - Debes buscar cuál era su correspondencia original. +// - Cada bloque de pulsaciones va separado por un guión. +// - Si un bloque tiene más de un número, debe ser siempre el mismo. +// - Ejemplo: +// Entrada: 6-666-88-777-33-3-33-888 +// Salida: MOUREDEV +// + +const cellphoneDial = (input) => { + const dial = { + 1: "1", + 2: "ABC2", + 3: "DEF3", + 4: "GHI4", + 5: "JKL5", + 6: "MNO6", + 7: "PQRS7", + 8: "TUV8", + 9: "WXYZ9", + 0: " 0", + "*": "*", + "#": "#", + }; + + return input + .split("-") + .map((char) => { + let char_pos = (char.length % dial[char[0]].length) - 1; + return dial[char[0]].slice(char_pos)[0]; + }) + .join(""); +}; + +const tests = { + inputs: [ + "6-666-88-777-33-3-33-888", + "8-444-6-33-0-8-666-0-7777-555-33-33-7", + "6-999-0-66-88-6-22-33-777-0-444-7777-0-99999-4444-77777-0-4444-2222-2222-0-3333-2222-4444", + "6-99999999-0-8-33-777777777-8", + ], + outputs: ["MOUREDEV", "TIME TO SLEEP", "MY NUMBER IS 947 422 324", "MY TEST"], +}; + +let errors = 0; +tests.inputs.forEach((input, index) => { + const result = cellphoneDial(input); + if (result != tests.outputs[index]) { + errors += 1; + console.log( + `Error - input: ${input}, expected: ${tests.outputs[index]}, result: ${result}` + ); + } +}); +console.log(`Errors: ${errors}`); From b9495c59bdbf56a12b937733c05d4fddf5e35083 Mon Sep 17 00:00:00 2001 From: Marco Torres Date: Sat, 29 Jul 2023 06:22:51 -0700 Subject: [PATCH 2/6] Reto #10 - Rust --- .../Reto #10 - LA API [Media]/rust/marcoatrs.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Retos/Reto #10 - LA API [Media]/rust/marcoatrs.rs diff --git a/Retos/Reto #10 - LA API [Media]/rust/marcoatrs.rs b/Retos/Reto #10 - LA API [Media]/rust/marcoatrs.rs new file mode 100644 index 0000000000..89568c8195 --- /dev/null +++ b/Retos/Reto #10 - LA API [Media]/rust/marcoatrs.rs @@ -0,0 +1,16 @@ +use std::collections::HashMap; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let url = "https://dog.ceo/api/breeds/image/random"; + + // Realizar la solicitud GET + let response = reqwest::get(url) + .await? + .json::>() + .await?; + + println!("{:#?}", response); + + Ok(()) +} \ No newline at end of file From 2c267ce5ecc0121862614fb1dc8c6ed030b3f9e2 Mon Sep 17 00:00:00 2001 From: Jordi Ayala Date: Sat, 29 Jul 2023 08:26:23 -0600 Subject: [PATCH 3/6] Reto #27 - Java --- .../java/asjordi.java" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "Retos/Reto #27 - CUENTA ATR\303\201S [Media]/java/asjordi.java" diff --git "a/Retos/Reto #27 - CUENTA ATR\303\201S [Media]/java/asjordi.java" "b/Retos/Reto #27 - CUENTA ATR\303\201S [Media]/java/asjordi.java" new file mode 100644 index 0000000000..9600fb7ef2 --- /dev/null +++ "b/Retos/Reto #27 - CUENTA ATR\303\201S [Media]/java/asjordi.java" @@ -0,0 +1,23 @@ +public class Countdown { + + public static void main(String[] args) { + execute(10, 6); + } + + public static void execute(int start, int seconds) { + if (start > 0 && seconds > 0){ + for (int i = start; i >= 0; i--) { + System.out.println(i); + if (i == 0) break; + try{ + Thread.sleep(seconds * 1000); + } catch (Exception e){ + System.out.println("There was an error: " + e.getMessage()); + } + } + } else{ + throw new RuntimeException("Los parámetros tienen que ser enteros positivos mayores a 0"); + } + } + +} From 0d1b9d7dc5e83e8b6e7f4db56973fd7714a53e5b Mon Sep 17 00:00:00 2001 From: ShinMugenNoKabe Date: Sat, 29 Jul 2023 22:33:31 +0200 Subject: [PATCH 4/6] Resuelto reto 1 --- .../python/ShinMugenNoKabe.py" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" new file mode 100644 index 0000000000..988684c14d --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" @@ -0,0 +1,50 @@ +# 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") + +#from string import maketrans + +LEETCODE = { + "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" +} + + +def translate_to_leetcode(text: str) -> str: + return "".join([LEETCODE.get(char.lower(), char) for char in text]) + + +def main(): + text = input(translate_to_leetcode("Escribe un texto: ")) + print(translate_to_leetcode(text)) + + +if __name__ == "__main__": + main() \ No newline at end of file From 73b2fe0c1f1df611a9743b506ec37e9d6e253c16 Mon Sep 17 00:00:00 2001 From: ShinMugenNoKabe Date: Sat, 29 Jul 2023 22:44:10 +0200 Subject: [PATCH 5/6] Retos resueltos --- .../python/ShinMugenNoKabe.py" | 2 -- 1 file changed, 2 deletions(-) diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" index 988684c14d..08a97e3079 100644 --- "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/ShinMugenNoKabe.py" @@ -5,8 +5,6 @@ # con el alfabeto y los números en "leet". # (Usa la primera opción de cada transformación. Por ejemplo "4" para la "a") -#from string import maketrans - LEETCODE = { "a": "4", "b": "I3", From 598f650f10cfd3501d32f3a7e2a35b4d372e8f35 Mon Sep 17 00:00:00 2001 From: ShinMugenNoKabe Date: Sat, 29 Jul 2023 23:02:28 +0200 Subject: [PATCH 6/6] Reto #11 - Python --- .../python/ShinMugenNoKabe.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/ShinMugenNoKabe.py" diff --git "a/Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/ShinMugenNoKabe.py" "b/Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/ShinMugenNoKabe.py" new file mode 100644 index 0000000000..76193c6ba1 --- /dev/null +++ "b/Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/ShinMugenNoKabe.py" @@ -0,0 +1,14 @@ +def get_paramteres(url: str) -> list[str]: + if not "?" in url: + return [] + + query = url.split("?")[1] + params = query.split("&") + + return [param.split("=")[1] for param in params] + + +if __name__ == "__main__": + result = get_paramteres("https://retosdeprogramacion.com?year=2023&challenge=0") + assert result == ["2023", "0"] + print(result) \ No newline at end of file