From 025d1d44e139e31dbb0b207dfa51d3a8d50cb79e Mon Sep 17 00:00:00 2001 From: FabianTorres Date: Sun, 1 Oct 2023 17:24:51 -0500 Subject: [PATCH 01/65] New Solution: Reto #1 - Python --- .../python/nftorres.py" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/nftorres.py" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/nftorres.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/nftorres.py" new file mode 100644 index 0000000000..1993465026 --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/nftorres.py" @@ -0,0 +1,44 @@ +"""This script shows the solution to exercise "Reto #0: EL FAMOSO FIZZ BUZZ" from Brais Moure's official website.""" + + +def main() -> None: + """ + Main function of the program. This function requests a text in natural language and translates it into basic language 'Leet'. + """ + natural_text = input("\nMessage: ") + leet_text = leet_translator(natural_text) + print("Traduction:", leet_text) + + +def leet_translator(natural_text: str) -> str: + """This function translate a natural language text into 'Basic Leet' language text. + + Args: + natural_text (str): natural language text entered by the user + + Returns: + str: translation of the text in "Basic Leet" + """ + replace_characters = { + "A": "4", + "B": "8", + "C": "<", + "E": "3", + "G": "9", + "H": "#", + "I": "1", + "O": "0", + "S": "5", + "T": "7", + } + + leet_text = "".join( + replace_characters[c.upper()] if c.upper() in replace_characters else c + for c in natural_text + ) + + return leet_text + + +if __name__ == "__main__": + main() From cf6b93322a0c3d374033654b579afdde432d23e3 Mon Sep 17 00:00:00 2001 From: Sandy Date: Mon, 2 Oct 2023 17:08:57 -0400 Subject: [PATCH 02/65] El famoso fizz buzz --- .../javascript/sandyaverhoff.js" | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandyaverhoff.js" diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandyaverhoff.js" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandyaverhoff.js" new file mode 100644 index 0000000000..0533c0acb2 --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandyaverhoff.js" @@ -0,0 +1,10 @@ +for(var i = 1; i <= 100; i++) { + if(i % 3 === 0 && i % 5 === 0) + console.log('fizzbuzz'); + else if(i % 3 === 0) + console.log('fizz'); + else if(i % 5 === 0) + console.log('buzz'); + else + console.log(i); +} \ No newline at end of file From 9888c390cee978d33f46c3a0ccfaa2f1af87e3f3 Mon Sep 17 00:00:00 2001 From: Sandy Date: Mon, 2 Oct 2023 17:14:54 -0400 Subject: [PATCH 03/65] El lenguaje hacker --- .../javascript/sandybierhoff.js" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/sandybierhoff.js" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/sandybierhoff.js" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/sandybierhoff.js" new file mode 100644 index 0000000000..9bce31bfd7 --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/sandybierhoff.js" @@ -0,0 +1,57 @@ + +function toHackerLanguage(text) { + + text = text.toLowerCase(); + + let traductionTable = { + a: ['4', '/\\', '@', '/-\\', '^', 'aye', '(L', 'Д]'], + b: ['I3', '8', '13', '|3', 'ß', '!3', '(3', '/3', ')3', '|-]', 'j3', '6'], + c: ['[', '¢', '{', '<', '(', '©'], + d: [')', '|)', '(|', '[)', 'I>', '|>', '?', 'T)', 'I7', 'cl', '|}', '>', '|]'], + e: ['3','&','£','€','ë','[-','|=-'], + f: ['|=', 'ƒ', '|#', 'ph', '/=', 'v'], + g: ['&','6','(_+','9','C-','gee','(?,','[,','{,','<-','(.'], + h: ['#', '/-/', '[-]', ']-[', ')-(', '(-)', ':-:', '|~|', '|-|', ']~[', '}{', '!-!', '1-1', '\-/', 'I+I', '/-\\'], + i: ['1', '[]', '|', '!', 'eye', '3y3', ']['], + j: [',_|', '_|', '._|', '._]', '_]', ',_]', ']', ';', '1'], + k: ['>|', '|<', '/<', '1<', '|c', '|(', '|{'], + l: ['1', '£', '7', '|_', '|'], + m: ['JVI', '[V]', '[]V[]', '|\/|', '^^', '<\/>', '{V}', '(v)', '(V)', '|V|', 'nn', 'IVI', '1^1', 'ITI', 'JTI'], + n: ['^/', '|\|', '/\/', '[\]', '<\>', '{\}', '|V', '/V', 'И', '^', 'ท'], + o: ['0', 'Q', '()', 'oh', '[]', 'p', '<>', 'Ø'], + p: ['|*', '|o', '|º', '?', '|^', '|>', '|"', '9', '[]D', '|°', '|7'], + q: ['(_,)', '9', '()_', '2', '0_', '<|', '&'], + r: ['I2', '|`', '|~', '|?', '/2', '|^', 'lz', '|9', '2', '12', '®', '[z', 'Я', '.-', '|2', '|-'], + s: ['5', '$', 'z', '§', 'ehs', 'es', '2'], + t: ['7', '+', '-|-', '']['', '†', '"|"', '~|~'], + u: ['(_)', '|_|', 'v', 'L|', 'µ', 'บ'], + v: ['|/', '\|'], + w: ['\/\/', 'VV', '\N', '\^/', '(n)', '\V/', '\X/', '\|/', '\_|_/', '\_:_/', 'Ш', 'Щ', 'uu', '2u', '\\//\\//', 'พ', 'v²'], + x: ['><', 'Ж', '}{', 'ecks', '×', '?', ')(', ']['], + y: ['j', '`/', 'Ч', '7'], + z: ['2', '7_', '-/_', '%', '>_', 's', '~/_', '-\_', '-|_'], + 0: ['o', '()'], + 1: ['L', 'I'], + 2: ['R', 'Z'], + 3: ['E'], + 4: ['A'], + 5: ['S'], + 6: ['b', 'G'], + 7: ['T', 'L'], + 8: ['B'], + 9: ['g', 'q'] + } + + let traduction = []; + + for(var i=0; i < text.length; i++) { + if(text[i] in traductionTable) { + let position = Math.round(Math.random() * traductionTable[text[i]].length); + traduction.push(traductionTable[text[i]][position]); + } + } + + return traduction.join(''); +} + +console.log( toHackerLanguage('Sandy Averhoff') ); \ No newline at end of file From 5f2783a3aac877cae7ac964fd6e3da3c6a5c0645 Mon Sep 17 00:00:00 2001 From: Leandro Espino Date: Tue, 3 Oct 2023 19:01:55 -0600 Subject: [PATCH 04/65] Reto #39 - pyhton --- .../python/EspinoLeandroo.py" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/EspinoLeandroo.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/EspinoLeandroo.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/EspinoLeandroo.py" new file mode 100644 index 0000000000..b80a57b289 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/EspinoLeandroo.py" @@ -0,0 +1,12 @@ +def triples_pitagoricos(maximo): + triples = [] + for a in range(1, maximo + 1): + for b in range(a, maximo + 1): + c = (a**2 + b**2)**0.5 # Calcula la hipotenusa + if c.is_integer() and c <= maximo: + triples.append((a, b, int(c))) + return triples + +maximo = 100 +resultado = triples_pitagoricos(maximo) +print(resultado) From 966c5fe79b6cc427e7d748c933eccbc2cb8e987a Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez Date: Tue, 3 Oct 2023 20:13:03 -0600 Subject: [PATCH 05/65] Reto #39 - JavaScript --- .../javascript/ricardo-fdz.js" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/ricardo-fdz.js" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/ricardo-fdz.js" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/ricardo-fdz.js" new file mode 100644 index 0000000000..e57bcdeffa --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/ricardo-fdz.js" @@ -0,0 +1,17 @@ +const getTriplex = (limit) => { + let triplex= []; + for (let p=2; ((p * p) + 1) <= limit; p++) { + for (let q = 1; q < p; q++) { + let a = (p * p) + (q * q); + if(a<=limit){ + let b = (p * p) - (q * q); + let c = 2 * p * q; + triplex.push([a, b, c]); + } + } + } + return triplex; +}; + +const res = getTriplex(10); +console.log(res); From f4ab7c2e1fe2c857a91173140b0bba33a44897ff Mon Sep 17 00:00:00 2001 From: jcdm60 Date: Tue, 3 Oct 2023 23:59:59 -0400 Subject: [PATCH 06/65] Reto #39 - Python --- .../python/jcdm60.py" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" new file mode 100644 index 0000000000..27a36b25e0 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" @@ -0,0 +1,39 @@ +# Reto #39: Triples pitagóricos +#### Dificultad: Media | Publicación: 02/10/23 | Corrección: 09/10/23 + +## Enunciado + +# +# Crea una función que encuentre todos los triples pitagóricos +# (ternas) menores o iguales a un número dado. +# - Debes buscar información sobre qué es un triple pitagórico. +# - La función únicamente recibe el número máximo que puede +# aparecer en el triple. +# - Ejemplo: Los triples menores o iguales a 10 están +# formados por (3, 4, 5) y (6, 8, 10). +# + + +class PythagoreanTriplesFinder: + def __init__(self, maximum): + self.maximum = maximum + self.triples = [] + + def find_pythagorean_triples(self): + for a in range(1, self.maximum + 1): + for b in range(a, self.maximum + 1): + c_square = a ** 2 + b ** 2 + c = int(c_square ** 0.5) + if c <= self.maximum and c_square == c ** 2: + self.triples.append((a, b, c)) + + def get_triples(self): + return self.triples + +# Example usage: +max_value = 20 +triples_finder = PythagoreanTriplesFinder(max_value) +triples_finder.find_pythagorean_triples() +triples = triples_finder.get_triples() +print(triples) + From 7e14fb3a4384c9348506821da949842475622978 Mon Sep 17 00:00:00 2001 From: jcdm60 Date: Wed, 4 Oct 2023 00:03:05 -0400 Subject: [PATCH 07/65] Reto #39 - Python --- .../python/jcdm60.py" | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" index 27a36b25e0..7d9898596a 100644 --- "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/jcdm60.py" @@ -30,10 +30,10 @@ def find_pythagorean_triples(self): def get_triples(self): return self.triples -# Example usage: -max_value = 20 -triples_finder = PythagoreanTriplesFinder(max_value) -triples_finder.find_pythagorean_triples() -triples = triples_finder.get_triples() -print(triples) +if __name__ == "__main__": + max_value = 10 + triples_finder = PythagoreanTriplesFinder(max_value) + triples_finder.find_pythagorean_triples() + triples = triples_finder.get_triples() + print(triples) From ad42c52321a41082333fe148c1e67e742b89f1a5 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Wed, 4 Oct 2023 07:25:13 +0200 Subject: [PATCH 08/65] Reto #38 - Kotlin --- .../kotlin/pisanowp.kt | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Retos/Reto #38 - LAS SUMAS [Media]/kotlin/pisanowp.kt diff --git a/Retos/Reto #38 - LAS SUMAS [Media]/kotlin/pisanowp.kt b/Retos/Reto #38 - LAS SUMAS [Media]/kotlin/pisanowp.kt new file mode 100644 index 0000000000..8659ae7b90 --- /dev/null +++ b/Retos/Reto #38 - LAS SUMAS [Media]/kotlin/pisanowp.kt @@ -0,0 +1,107 @@ +fun main() { + + /* + * Reto #38 25/09/2023 LAS SUMAS + * + * Crea una función que encuentre todas las combinaciones de los números + * de una lista que suman el valor objetivo. + * - La función recibirá una lista de números enteros positivos + * y un valor objetivo. + * - Para obtener las combinaciones sólo se puede usar + * una vez cada elemento de la lista (pero pueden existir + * elementos repetidos en ella). + * - Ejemplo: Lista = [1, 5, 3, 2], Objetivo = 6 + * Soluciones: [1, 5] y [1, 3, 2] (ambas combinaciones suman 6) + * (Si no existen combinaciones, retornar una lista vacía) + * + */ + +// val lista = listOf(1, 5, 3) +// val objetivo = 6 + + val lista = listOf(1, 5, 3, 2,4,1) + val objetivo = 7 + + println( "Lista => ${lista}") + println( "Combinaciones para conseguir $objetivo => ${getCombinaciones(lista, objetivo)}" ) + +} + + +fun getCombinaciones(lista: List, objetivo: Int): List> { + + var combinaciones = mutableListOf>() + combinaciones.add(lista) + + // Voy a crear una lista de listas con TODAS las posibles combinaciones de números + combinaciones = getAllCombinaciones(combinaciones) + + // Ahora solo me quedo con aquellas, cuya suma de elementos sea igual al objetivo + val aux = combinaciones.filter{ + it.sum() == objetivo + } + + // ... Y quito los duplciados + val conjuntoDeListas = aux.toSet() + val listaSinDuplicados = conjuntoDeListas.toList() + + + // Devuelvo el resutlado + return listaSinDuplicados + +} + +fun getAllCombinaciones(combinaciones: MutableList>): MutableList> { + + var retornoCombinaciones = mutableListOf>() + + //println ("getAllCombinaciones => ${combinaciones}") + + + if ( ( combinaciones.size >= 1 ) + && ( combinaciones[0].size > 2 ) ){ + combinaciones.forEach(){ + retornoCombinaciones.add(it) + val dummyVariaciones = getCombinacion(it) + //println(dummyVariaciones) + + dummyVariaciones.forEach(){ + retornoCombinaciones.add(it) + getAllCombinaciones(mutableListOf>(it)).forEach(){ + retornoCombinaciones.add(it) + } + + } + } + + } + + return retornoCombinaciones + +} + + +fun getCombinacion(lista: List): List> { + + var combinacion = mutableListOf() + var combinaciones = mutableListOf>() + + + (0 until lista.size).forEach() { i -> + + (0 until lista.size).forEach() { j -> + if ( i!=j ){ + // Para no tomar el valor guia + combinacion.add( lista[j]) + + } + } + + combinaciones.add(combinacion) + + combinacion = mutableListOf() + + } + + return combinaciones +} \ No newline at end of file From 28c9fc36cbb99ab8bceb428c2bd964af44ed942c Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Wed, 4 Oct 2023 07:47:45 +0200 Subject: [PATCH 09/65] Reto #39 - Kotlin --- .../kotlin/pisanowp.kt" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/kotlin/pisanowp.kt" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/kotlin/pisanowp.kt" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/kotlin/pisanowp.kt" new file mode 100644 index 0000000000..d866c3b185 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/kotlin/pisanowp.kt" @@ -0,0 +1,50 @@ +fun main() { + + /* + * Reto #39 02/10/2023 TRIPLES PITAGÓRICOS + * + * Crea una función que encuentre todos los triples pitagóricos + * (ternas) menores o iguales a un número dado. + * - Debes buscar información sobre qué es un triple pitagórico. + * - La función únicamente recibe el número máximo que puede + * aparecer en el triple. + * - Ejemplo: Los triples menores o iguales a 10 están + * formados por (3, 4, 5) y (6, 8, 10). + */ + + // Tres números enteros a , b , c que satisfacen la ecuación del teorema de Pitágoras + // ( a 2 + b 2 = c 2 ) son llamados triples Pitagóricos . + + val numMaximo = 10 + + println("Los triples pitagoricos menores o iguales a $numMaximo son ${findTriplesPitagoricos(numMaximo)}") + + +} + +fun findTriplesPitagoricos(numMaximo: Int): List> { + var triplesPitagoricos = mutableListOf>() + + (1..numMaximo).forEach { a -> + + (a..numMaximo).forEach { b -> + + (b..numMaximo).forEach { c -> + + if ((a !== b) && (b !== c) && (a !== c)) { + if ((a * a + b * b) == (c * c)) { + triplesPitagoricos.add(listOf(a, b, c)) + + } + + } + + } // c + + } // b + + } // a + + return triplesPitagoricos + +} From a8dd7bb244ac1ddc1caff7bc3651fd92bea14ddb Mon Sep 17 00:00:00 2001 From: brand Date: Wed, 4 Oct 2023 01:03:56 -0600 Subject: [PATCH 10/65] Reto #39 - c++ --- .../c++/AlexCoffing.cpp" | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/c++/AlexCoffing.cpp" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/c++/AlexCoffing.cpp" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/c++/AlexCoffing.cpp" new file mode 100644 index 0000000000..3a53056f83 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/c++/AlexCoffing.cpp" @@ -0,0 +1,65 @@ +#include + +#define lli long long int +#define endL '\n' + +using namespace std; + +void terna(lli); +bool mcd(lli,lli); + +int main() { + lli n; + cin>>n; + terna(n); + return 0; + } + +bool mcd(lli p, lli q) { + lli resp; + do { + resp = q; + q = p%q; + p = resp; + } + while(q!=0); + if(resp==1) + return 1; + else + return 0; + } + +void terna(lli maxi) { + lli p(2),q(1),a((p*p)-(q*q)),b(2*p*q),c((a*a)+(b*b)),i,j; + c = sqrt(c); + while(c<=maxi) { + i=1; + while(c*i<=maxi) { + if(amaxi && j<=1); + } + } From 7bb200a11f3dc54691a60af814fddb042a053ac4 Mon Sep 17 00:00:00 2001 From: AlbertoVf Date: Wed, 4 Oct 2023 13:03:41 +0200 Subject: [PATCH 11/65] reto#25 - python --- .../python/albertovf.py" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/python/albertovf.py" diff --git "a/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/python/albertovf.py" "b/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/python/albertovf.py" new file mode 100644 index 0000000000..8191d500d1 --- /dev/null +++ "b/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/python/albertovf.py" @@ -0,0 +1,21 @@ +class KEYS: + ARRIBA = "arriba" + ABAJO = "abajo" + IZQUIERDA = "izquierda" + DERECHA = "derecha" + A = "a" + B = "b" + + +def isKonami(entrada:[str]): + entrada = list(map(lambda x: x.lower(), entrada)) + codigo_konami = [ KEYS.ARRIBA, KEYS.ARRIBA, KEYS.ABAJO, KEYS.ABAJO, KEYS.IZQUIERDA, KEYS.DERECHA, KEYS.IZQUIERDA, KEYS.DERECHA, KEYS.B, KEYS.A, ] + + return entrada == codigo_konami + + +def reto(): + entrada = input('Introduce el codigo coname con letras: ') + print(isKonami(entrada.split(' '))) + +reto() \ No newline at end of file From f61b5a31153d159d21637cb0ae55f5a29bb3fb36 Mon Sep 17 00:00:00 2001 From: AlbertoVf Date: Wed, 4 Oct 2023 13:24:24 +0200 Subject: [PATCH 12/65] reto#34 - python --- .../python/albertovf.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Retos/Reto #34 - EL TXT [Media]/python/albertovf.py diff --git a/Retos/Reto #34 - EL TXT [Media]/python/albertovf.py b/Retos/Reto #34 - EL TXT [Media]/python/albertovf.py new file mode 100644 index 0000000000..7b1c361039 --- /dev/null +++ b/Retos/Reto #34 - EL TXT [Media]/python/albertovf.py @@ -0,0 +1,20 @@ +import os + +file_name = "pruebas.txt" + +if os.path.exists(file_name): + print("Fichero existente") + text = input("Escribe para continuar. Escribe para sobreescribir: ") + os.remove(file_name) if (text == "delete") else print(open(file_name, "r").read()) + +file = open(file_name, "a") + +while True: + text = input("Escribe el texto. Escribe para salir: ") + if text == "exit": + break + + file.write(f'{text}\n') + file.flush() + +file.close() From e6060350be4f3335fb6f7eb807316a968b7fe8da Mon Sep 17 00:00:00 2001 From: patriciotrujilllo Date: Wed, 4 Oct 2023 08:41:18 -0300 Subject: [PATCH 13/65] Reto #39-Javascript resolve --- .../javascript/patriciotrujilllo.js" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" new file mode 100644 index 0000000000..a10854113b --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" @@ -0,0 +1,41 @@ +/* + * Crea una función que encuentre todos los triples pitagóricos + * (ternas) menores o iguales a un número dado. + * - Debes buscar información sobre qué es un triple pitagórico. + * - La función únicamente recibe el número máximo que puede + * aparecer en el triple. + * - Ejemplo: Los triples menores o iguales a 10 están + * formados por (3, 4, 5) y (6, 8, 10). + */ + +//la base es (3,4,5) y para obtener los demas se multiplica por un entero para mantener +//la proporcion del triangulo + +const tiplesPitagoricos = (numeroMax) =>{ + const a = 3 + const b = 4 + const c = 5 + + if(numeroMax Date: Wed, 4 Oct 2023 08:53:57 -0300 Subject: [PATCH 14/65] Add comment --- .../javascript/patriciotrujilllo.js" | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" index a10854113b..2e4ea4894e 100644 --- "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/javascript/patriciotrujilllo.js" @@ -35,7 +35,7 @@ const tiplesPitagoricos = (numeroMax) =>{ } return allTiples } -console.log(tiplesPitagoricos(5)) -console.log(tiplesPitagoricos(10)) -console.log(tiplesPitagoricos(13)) -console.log(tiplesPitagoricos(15)) \ No newline at end of file +console.log(tiplesPitagoricos(5)) //--> [ [ 3, 4, 5 ] ] +console.log(tiplesPitagoricos(10)) //--> [ [ 3, 4, 5 ], [ 6, 8, 10 ] ] +console.log(tiplesPitagoricos(13)) //--> [ [ 3, 4, 5 ], [ 6, 8, 10 ] ] +console.log(tiplesPitagoricos(15)) //--> [ [ 3, 4, 5 ], [ 6, 8, 10 ], [ 9, 12, 15 ] ] \ No newline at end of file From f8ea17c6f288acf218d79a6abcd32559ce7dd90a Mon Sep 17 00:00:00 2001 From: Sandy Date: Wed, 4 Oct 2023 07:58:54 -0400 Subject: [PATCH 15/65] rename file --- .../javascript/sandybierhoff.js" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandyaverhoff.js" => "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandybierhoff.js" (100%) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandyaverhoff.js" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandybierhoff.js" similarity index 100% rename from "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandyaverhoff.js" rename to "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/sandybierhoff.js" From fbb28082ddadfc20748d16f87c06e8cfcec50335 Mon Sep 17 00:00:00 2001 From: AlbertoVf Date: Wed, 4 Oct 2023 14:15:04 +0200 Subject: [PATCH 16/65] reto#38 - typescript --- .../typescript/albertovf.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Retos/Reto #38 - LAS SUMAS [Media]/typescript/albertovf.ts diff --git a/Retos/Reto #38 - LAS SUMAS [Media]/typescript/albertovf.ts b/Retos/Reto #38 - LAS SUMAS [Media]/typescript/albertovf.ts new file mode 100644 index 0000000000..e575952005 --- /dev/null +++ b/Retos/Reto #38 - LAS SUMAS [Media]/typescript/albertovf.ts @@ -0,0 +1,28 @@ +const combinar = (lista: number[]) => { + const combinaciones: number[][] = [[]]; + + for (let i in lista) { + const value = lista[Number(i)]; + const temp: number[][] = combinaciones.map( + (combination) => [value, ...combination] + ); + combinaciones.push(...temp); + } + return combinaciones; +}; + +const sumatorio = (arr: number[]) => arr.reduce((acc, value) => acc + value, 0); + +const reto = (numeros: number[], resultado: number) => { + if (resultado < 1) return []; + if (numeros.length === 0) return []; + if (!numeros.every((n) => n >= 0)) return []; + + + return combinar(numeros).filter((nms) => sumatorio(nms) === resultado); +} + +const list: number[] = [19, 1, 20, 0, 2, 18, 15, 5]; +const target: number = 6; + +console.log(reto(list, target)); \ No newline at end of file From 415c59de806a143956a56649005b7f0e69027a65 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 4 Oct 2023 16:24:05 +0200 Subject: [PATCH 17/65] reto #39 python --- .../python/javierfiestasbotella.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/javierfiestasbotella.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/javierfiestasbotella.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/javierfiestasbotella.py" new file mode 100644 index 0000000000..d1c8e8bb88 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/javierfiestasbotella.py" @@ -0,0 +1,31 @@ +'''/* + * Crea una función que encuentre todos los triples pitagóricos + * (ternas) menores o iguales a un número dado. + * - Debes buscar información sobre qué es un triple pitagórico. + * - La función únicamente recibe el número máximo que puede + * aparecer en el triple. + * - Ejemplo: Los triples menores o iguales a 10 están + * formados por (3, 4, 5) y (6, 8, 10). +a=m^2 - n^2 , b=2mn y c=m^2 + n^2 . + +Por ejemplo, si m=4 y n=3 entonces, + +a=4 2 – 3 2 =16 – 9=7 +b=2 × 4 × 3=24 +c=4 2 + 3 2 =16 + 9=25 +Usando la ecuación a^2 + b^2 =c^2 + */''' + +def triple_pitagorico(max): + triples = [] + for m in range(2, max + 1): + for n in range(1, m): + a = m**2 - n**2 + b = 2 * m * n + c = m**2 + n**2 + if c <= max: + triples.append([a, b, c]) + return triples +max = 10 +solution = triple_pitagorico(max) +print(*solution) \ No newline at end of file From d4861f4fece3b32d59b9d83af83a36b640d838f2 Mon Sep 17 00:00:00 2001 From: Raul Garcia Date: Wed, 4 Oct 2023 16:26:52 +0200 Subject: [PATCH 18/65] Reto #39 - Python --- .../python/raulG91.py" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/raulG91.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/raulG91.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/raulG91.py" new file mode 100644 index 0000000000..8c88b0eb74 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/raulG91.py" @@ -0,0 +1,15 @@ +from math import pow +def find_triples(max_number): + triples = [] + for value in range(1,max_number+1): + for value2 in range(value+1,max_number+1): + sum = value**2 + value2**2 + square_root = sum **0.5 + + if square_root.is_integer() and square_root <= max_number: + tuple = (value,value2,int(square_root)) + triples.append(tuple) + return triples + +result = find_triples(max_number=50) +print(result) \ No newline at end of file From eb1eedb5f5322e53bb618569574887cd248091ac Mon Sep 17 00:00:00 2001 From: allbertoMD Date: Wed, 4 Oct 2023 17:07:45 +0200 Subject: [PATCH 19/65] Reto 39 - Swift --- .../swift/allbertoMD.swift" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/swift/allbertoMD.swift" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/swift/allbertoMD.swift" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/swift/allbertoMD.swift" new file mode 100644 index 0000000000..db38a67a05 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/swift/allbertoMD.swift" @@ -0,0 +1,24 @@ +import Foundation + +func findPythagoreanTriplesUpTo(number max: Int) { + for a in 1...max { + + for b in a...max { + + for c in b...max { + if a * a + b * b == c * c { + print("(\(a), \(b), \(c)) is a Pythaforean Triple") + } + } + } + } +} + + +print("Introduce a max possitive number") +if let input = readLine(), let argument = Int(input) { + findPythagoreanTriplesUpTo(number: argument) +} else { + print("number most be Int") +} + From 67cbb6f5bb0d0e5385a453c541b1058bb62eb373 Mon Sep 17 00:00:00 2001 From: Francisco Fernandez Date: Wed, 4 Oct 2023 18:42:06 +0200 Subject: [PATCH 20/65] Reto #39 - Php --- .../php/pacofer71.php" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/php/pacofer71.php" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/php/pacofer71.php" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/php/pacofer71.php" new file mode 100644 index 0000000000..fd46b7ddf7 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/php/pacofer71.php" @@ -0,0 +1,29 @@ + $x * $x; + $cuadrados = array_map($hacerCuadrados, $numeros); //tenemos un array con todos los cuadrados + $ternas = []; + + foreach ($cuadrados as $k => $v) { + for ($i = $k + 1; $i < count($cuadrados); $i++) { + $suma = $v + $cuadrados[$i]; + if (in_array($suma, $cuadrados)) { + $ternas[] = [$numeros[$k], $numeros[$i], $numeros[array_search($suma, $cuadrados)]]; + } + } + } + return $ternas; +} + +//Comprobacion +var_dump(encuentraTriples(10)); From 05094b200122aac70f35b67a129579f239853cc4 Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:58:34 -0300 Subject: [PATCH 21/65] Create jlcontini.py - Reto #0 Reto #0 --- .../python/jlcontini.py" | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" new file mode 100644 index 0000000000..1bf929ed0b --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -0,0 +1,2 @@ +# Reto #0 - EL FAMOSO FIZZ BUZZ + From 53db6641d554022c51b198920449cf2721e55505 Mon Sep 17 00:00:00 2001 From: Elez95 Date: Wed, 4 Oct 2023 15:04:38 -0300 Subject: [PATCH 22/65] Reto #5 - java --- .../Reto #5 - HOLA MUNDO [F\303\241cil]/java/Elez95.java" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/java/Elez95.java" diff --git "a/Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/java/Elez95.java" "b/Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/java/Elez95.java" new file mode 100644 index 0000000000..14850d9c42 --- /dev/null +++ "b/Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/java/Elez95.java" @@ -0,0 +1,7 @@ +public class Elez95 { + + public static void main (String [] args) { + System.out.println("!Hola Mundo!"); + } + +} \ No newline at end of file From 24cd9c3ccf8cdd218c74ae9c2dd8c8b2800fbf10 Mon Sep 17 00:00:00 2001 From: Elez95 Date: Wed, 4 Oct 2023 15:07:18 -0300 Subject: [PATCH 23/65] Reto #5 - sql --- "Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/sql/elez95.sql" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/sql/elez95.sql" diff --git "a/Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/sql/elez95.sql" "b/Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/sql/elez95.sql" new file mode 100644 index 0000000000..aff06d5dbc --- /dev/null +++ "b/Retos/Reto #5 - HOLA MUNDO [F\303\241cil]/sql/elez95.sql" @@ -0,0 +1 @@ +SELECT '!Hola Mundo!'; \ No newline at end of file From 9068ed751e1989102dbbacf28cd38a796ae0e9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa=20Bernabeu?= Date: Wed, 4 Oct 2023 20:09:34 +0200 Subject: [PATCH 24/65] Reto #8 - Python --- .../python/Bombkid85.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/python/Bombkid85.py diff --git a/Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/python/Bombkid85.py b/Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/python/Bombkid85.py new file mode 100644 index 0000000000..233e355d1f --- /dev/null +++ b/Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/python/Bombkid85.py @@ -0,0 +1,9 @@ +import time + +def my_random(): + seed = int(time.time()) + seed = (seed * 6364136223846793005 + 1) & 0xFFFFFFFFFFFFFFFF + random_number = (seed % 101) + return random_number + +print(my_random()) From b6d2f064e67c129caddeb8574b5da6c786850393 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 4 Oct 2023 20:32:43 +0200 Subject: [PATCH 25/65] Reto #39 - Python --- .../python/HailToTheChaos.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py diff --git a/Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py b/Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py new file mode 100644 index 0000000000..65b1fb7b63 --- /dev/null +++ b/Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py @@ -0,0 +1,43 @@ +''' + 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 +''' + +KEYBOARD = { + "0": " ", + "1": ",.?!", + "2": "ABC", + "3": "DEF", + "4": "GHI", + "5": "JKL", + "6": "MNO", + "7": "PQRS", + "8": "TUV", + "9": "WXYZ" +} + + +def convert_T9_to_text(input: str) -> str: + output = "" + + keystrokes = input.split("-") + + for keystroke in keystrokes: + if keystroke[0] in KEYBOARD.keys() and len(keystroke) <= len(KEYBOARD[keystroke[0]]): + output += KEYBOARD[keystroke[0]][len(keystroke)-1] + + return output + + +if __name__ == '__main__': + print(convert_T9_to_text("44-666-555-2-0-6-88-66-3-666-1111")) From 34a95b4ab6c2886027faec128f9cbce196ddbbbb Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 4 Oct 2023 20:34:31 +0200 Subject: [PATCH 26/65] Reto #30 - Python --- .../python/HailToTheChaos.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py diff --git a/Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py b/Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py new file mode 100644 index 0000000000..65b1fb7b63 --- /dev/null +++ b/Retos/Reto #30 - EL TECLADO T9 [Media]/python/HailToTheChaos.py @@ -0,0 +1,43 @@ +''' + 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 +''' + +KEYBOARD = { + "0": " ", + "1": ",.?!", + "2": "ABC", + "3": "DEF", + "4": "GHI", + "5": "JKL", + "6": "MNO", + "7": "PQRS", + "8": "TUV", + "9": "WXYZ" +} + + +def convert_T9_to_text(input: str) -> str: + output = "" + + keystrokes = input.split("-") + + for keystroke in keystrokes: + if keystroke[0] in KEYBOARD.keys() and len(keystroke) <= len(KEYBOARD[keystroke[0]]): + output += KEYBOARD[keystroke[0]][len(keystroke)-1] + + return output + + +if __name__ == '__main__': + print(convert_T9_to_text("44-666-555-2-0-6-88-66-3-666-1111")) From 4747b0cdc60b7ff3cd92f5a20a97f20baf509479 Mon Sep 17 00:00:00 2001 From: kodenook Date: Wed, 4 Oct 2023 15:55:04 -0300 Subject: [PATCH 27/65] Reto #21 - php Reto #21 fue resuelto en php. --- .../php/kodenook.php" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "Retos/Reto #21 - N\303\232MEROS PRIMOS GEMELOS [Media]/php/kodenook.php" diff --git "a/Retos/Reto #21 - N\303\232MEROS PRIMOS GEMELOS [Media]/php/kodenook.php" "b/Retos/Reto #21 - N\303\232MEROS PRIMOS GEMELOS [Media]/php/kodenook.php" new file mode 100644 index 0000000000..efcee95f7f --- /dev/null +++ "b/Retos/Reto #21 - N\303\232MEROS PRIMOS GEMELOS [Media]/php/kodenook.php" @@ -0,0 +1,64 @@ += count($numbers)) { + continue; + } + + if ($numbers[$i + 1] - $numbers[$i] === 2) { + $response .= '(' . $numbers[$i] . ',' . $numbers[$i + 1] . ') '; + } + } + + return $response; +} + +echo primeTwins(14) . PHP_EOL; +echo primeTwins(7) . PHP_EOL; +echo primeTwins(2) . PHP_EOL; From cb3fa73d7fa47ef7b3cabc4cc2a1a85cb258e6d9 Mon Sep 17 00:00:00 2001 From: marco cruz Date: Wed, 4 Oct 2023 13:11:36 -0600 Subject: [PATCH 28/65] Reto #30 - Javascript --- .../javascript/marcode24.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/marcode24.js diff --git a/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/marcode24.js b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/marcode24.js new file mode 100644 index 0000000000..7ddc453703 --- /dev/null +++ b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/marcode24.js @@ -0,0 +1,34 @@ +/* + * 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 getKeyboardT9Text = (numbers) => { + const KEYBOARD = { + 0: ' ', + 1: ',.?!', + 2: 'ABC', + 3: 'DEF', + 4: 'GHI', + 5: 'JKL', + 6: 'MNO', + 7: 'PQRS', + 8: 'TUV', + 9: 'WXYZ', + }; + return numbers + .split('-') + .reduce((acc, number) => acc + KEYBOARD[number[0]][number.length - 1], ''); +}; + +// Visita mi repo en GitHub para ver y correr los tests de este código --> https://github.com/marcode24/weekly-challenges From 57fb1fbdca56ed82aeef6e039a109f8764644729 Mon Sep 17 00:00:00 2001 From: marco cruz Date: Wed, 4 Oct 2023 13:15:22 -0600 Subject: [PATCH 29/65] Reto #31 - Javascript --- .../javascript/marcode24.js" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "Retos/Reto #31 - EL \303\201BACO [F\303\241cil]/javascript/marcode24.js" diff --git "a/Retos/Reto #31 - EL \303\201BACO [F\303\241cil]/javascript/marcode24.js" "b/Retos/Reto #31 - EL \303\201BACO [F\303\241cil]/javascript/marcode24.js" new file mode 100644 index 0000000000..067ebc3d86 --- /dev/null +++ "b/Retos/Reto #31 - EL \303\201BACO [F\303\241cil]/javascript/marcode24.js" @@ -0,0 +1,36 @@ +/* + * Crea una función que sea capaz de leer el número representado por el ábaco. + * - El ábaco se representa por un array con 7 elementos. + * - Cada elemento tendrá 9 "O" (aunque habitualmente tiene 10 para realizar operaciones) + * para las cuentas y una secuencia de "---" para el alambre. + * - El primer elemento del array representa los millones, y el último las unidades. + * - El número en cada elemento se representa por las cuentas que están a la izquierda del alambre. + * + * Ejemplo de array y resultado: + * ["O---OOOOOOOO", + * "OOO---OOOOOO", + * "---OOOOOOOOO", + * "OO---OOOOOOO", + * "OOOOOOO---OO", + * "OOOOOOOOO---", + * "---OOOOOOOOO"] + * + * Resultado: 1.302.790 + */ + +const getNumber = (abacus) => { + let number = 0; + const abacusLength = abacus.length; + + for (let rowIndex = 0; rowIndex < abacusLength; rowIndex++) { + const row = abacus[rowIndex]; + if (!/^[^-]*-{3}[^-]*$/.test(row) || row.length !== 12) { + number = 'Invalid abacus'; + break; + } + number += row.split('---')[0].length * (10 ** (abacusLength - rowIndex - 1)); + } + return number.toLocaleString('en-US'); +}; + +// Visita mi repo en GitHub para ver y correr los tests de este código --> https://github.com/marcode24/weekly-challenges From fa42467d4886e978a0a9f11b8c0a3c0d8b64645a Mon Sep 17 00:00:00 2001 From: marco cruz Date: Wed, 4 Oct 2023 13:24:23 -0600 Subject: [PATCH 30/65] Reto #32 - Javascript --- .../javascript/marcode24.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Retos/Reto #32 - LA COLUMNA DE EXCEL [Media]/javascript/marcode24.js diff --git a/Retos/Reto #32 - LA COLUMNA DE EXCEL [Media]/javascript/marcode24.js b/Retos/Reto #32 - LA COLUMNA DE EXCEL [Media]/javascript/marcode24.js new file mode 100644 index 0000000000..337a95e08d --- /dev/null +++ b/Retos/Reto #32 - LA COLUMNA DE EXCEL [Media]/javascript/marcode24.js @@ -0,0 +1,16 @@ +/* + * Crea una función que calcule el número de la columna de una hoja de Excel + * teniendo en cuenta su nombre. + * - Las columnas se designan por letras de la "A" a la "Z" de forma infinita. + * - Ejemplos: A = 1, Z = 26, AA = 27, CA = 79. + */ + +const columnToNumber = (column) => { + let number = 0; + for (let i = 0; i < column.length; i++) { + number = number * 26 + column.charCodeAt(i) - 64; + } + return number; +}; + +// Visita mi repo en GitHub para ver y correr los tests de este código --> https://github.com/marcode24/weekly-challenges From 18d628fad00a799b6e4c34db0e19754c52396b3a Mon Sep 17 00:00:00 2001 From: Kevin Rodriguez Date: Wed, 4 Oct 2023 14:34:08 -0500 Subject: [PATCH 31/65] =?UTF-8?q?Kevin=20Rodr=C3=ADguez=20submission=20for?= =?UTF-8?q?=20challenge=20#39?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../python/kevyder.py" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/kevyder.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/kevyder.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/kevyder.py" new file mode 100644 index 0000000000..03028cd8bc --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/kevyder.py" @@ -0,0 +1,36 @@ +import unittest + +def pythagorean_triples(number: int) -> list[tuple[int, int, int]]: + numbers = list(range(1, number + 1)) + triples = [] + for i, n in enumerate(numbers): + for m in numbers[i + 1::]: + result = (n**2 + m**2) ** 0.5 + if int(result) in numbers and result.is_integer(): + triples.append((n, m, int(result))) + return triples + +# Simple Test Cases +class TestPythagoreanTriples(unittest.TestCase): + + def test_with_small_range(self): + # Test with a small range of numbers + result = pythagorean_triples(10) + expected = [(3, 4, 5), (6, 8, 10)] + self.assertEqual(result, expected) + + def test_with_large_range(self): + # Test with a larger range of numbers + result = pythagorean_triples(20) + expected = [(3, 4, 5), (5, 12, 13), (6, 8, 10), (8, 15, 17), (9, 12, 15), (12, 16, 20)] + self.assertEqual(result, expected) + + def test_with_no_triples(self): + # Test when there are no Pythagorean triples in the range + result = pythagorean_triples(2) + expected = [] + self.assertEqual(result, expected) + + +if __name__ == "__main__": + unittest.main() From 3e0359db093d8d1597ebd17df51b26e6d176eac7 Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:42:30 -0300 Subject: [PATCH 32/65] Update jlcontini.py reto#0 --- .../python/jlcontini.py" | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" index 1bf929ed0b..df6c8af9e7 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -1,2 +1,50 @@ -# Reto #0 - EL FAMOSO FIZZ BUZZ +# Reto #0: EL FAMOSO "FIZZ BUZZ" +#### Dificultad: Fácil | Publicación: 26/12/22 | Corrección: 02/01/23 +## Enunciado +""" +``` +/* + * 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". + */ +``` +#### 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)**. +""" + + +fizz = "fizz" +buzz = "buzz" + + +def is_multiple(n1: int, n2: int) ->bool: + return n1 % n2 == 0 + + +def print_numbers_in_range(a, b): + for i in range(a, b+1): + + if is_multiple(i, 3) and is_multiple(i, 5): + print(fizz + buzz + "\n") + elif is_multiple(i, 3): + print(fizz + "\n") + elif is_multiple(i, 5): + print(buzz + "\n") + else: + print(str(i) + "\n") + + +def main(): + print_numbers_in_range(1, 100) + + + +main() From dd69d73301681218636bd412cf92d50a69c677af Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:58:47 -0300 Subject: [PATCH 33/65] cambio desde Code Web --- .../python/jlcontini.py" | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" index df6c8af9e7..fbd93875de 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -13,7 +13,8 @@ * - Múltiplos de 3 y de 5 a la vez por la palabra "fizzbuzz". */ ``` -#### Tienes toda la información extendida sobre los retos de programación semanales en **[retosdeprogramacion.com/semanales2023](https://retosdeprogramacion.com/semanales2023)**. +#### 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. From 8032a90f0e2aacfd6a3a3a78a8f66e370800550a Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:07:53 +0000 Subject: [PATCH 34/65] nueva actualizacion --- .../python/jlcontini.py" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" index fbd93875de..e22d63b09e 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -26,13 +26,14 @@ buzz = "buzz" -def is_multiple(n1: int, n2: int) ->bool: +def is_multiple(n1: int, n2: int) -> bool: return n1 % n2 == 0 def print_numbers_in_range(a, b): + for i in range(a, b+1): - + if is_multiple(i, 3) and is_multiple(i, 5): print(fizz + buzz + "\n") elif is_multiple(i, 3): From 56a8106e1d07d60f82339e6e3157f730bb2ef83b Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:10:02 +0000 Subject: [PATCH 35/65] nueva actualizacion --- .../python/jlcontini.py" | 2 -- 1 file changed, 2 deletions(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" index e22d63b09e..3ccb653616 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -31,9 +31,7 @@ def is_multiple(n1: int, n2: int) -> bool: def print_numbers_in_range(a, b): - for i in range(a, b+1): - if is_multiple(i, 3) and is_multiple(i, 5): print(fizz + buzz + "\n") elif is_multiple(i, 3): From 7a60819f97f0c1a61ced5e7cb15e9e51fa1adb15 Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:24:33 +0000 Subject: [PATCH 36/65] Algunas correciones de codigo --- .../python/jlcontini.py" | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" index 3ccb653616..6de17b38f1 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -26,8 +26,8 @@ buzz = "buzz" -def is_multiple(n1: int, n2: int) -> bool: - return n1 % n2 == 0 +def is_multiple(number: int, multiple: int) -> bool: + return number % multiple == 0 def print_numbers_in_range(a, b): @@ -47,4 +47,5 @@ def main(): -main() +if __name__ == "__main__": + main() From ce1c03c7443732f8e3fac5696c3a345bf4fff78d Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:29:14 +0000 Subject: [PATCH 37/65] Correccion string linea 4 "FizzBuzz" --- .../python/k3nvd.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/k3nvd.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/k3nvd.py" index d976db592e..b01d897f5f 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/k3nvd.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/k3nvd.py" @@ -1,7 +1,7 @@ n= int(input("Type a number: ")) for x in range(1,n): if x% 3==0 and x%5==0: - print(FizzBuzz) + print("FizzBuzz") elif x% 3==0: print("Fizz") elif x % 5==0: From 233029967efdc2295af930a5bd5bd1043f494c35 Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:30:09 +0000 Subject: [PATCH 38/65] Actualizacion archivo reto#0 jlcontini.py --- .../python/jlcontini.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" index 6de17b38f1..f90454ad48 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -30,7 +30,7 @@ def is_multiple(number: int, multiple: int) -> bool: return number % multiple == 0 -def print_numbers_in_range(a, b): +def print_numbers_in_range(a, b) -> str: for i in range(a, b+1): if is_multiple(i, 3) and is_multiple(i, 5): print(fizz + buzz + "\n") From 241c1e360b7534de2801c691058996efd260df91 Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:40:10 +0000 Subject: [PATCH 39/65] Correccion linea 12 (num %3==0) --- .../python/lzaruss.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/lzaruss.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/lzaruss.py" index b2f83adf97..27504650aa 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/lzaruss.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/lzaruss.py" @@ -9,7 +9,7 @@ """ def FizzBuzz(num : int) -> str: - if (num %3)and(num %5==0): + if (num %3==0)and(num %5==0): return "fizzbuzz" elif(num % 3 == 0): return "fizz" From a5901c17fe72b7d50db5d914bcd6d5b6d2a4c7e4 Mon Sep 17 00:00:00 2001 From: jlcontini <126628342+jlcontini@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:10:15 -0300 Subject: [PATCH 40/65] Update jlcontini.py --- .../python/jlcontini.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" index f90454ad48..b4b57cfb4e 100644 --- "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/jlcontini.py" @@ -19,7 +19,7 @@ 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)**. -""" +""" fizz = "fizz" From cafb4ac13f1cc5c28daddc1106d7bf16d908d36b Mon Sep 17 00:00:00 2001 From: Hans Escobar <60953384+hdescobarh@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:57:10 -0500 Subject: [PATCH 41/65] =?UTF-8?q?Soluci=C3=B3n=20reto=20#39=20con=20docume?= =?UTF-8?q?ntaci=C3=B3n=20y=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rust/hdescobarh.rs" | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/rust/hdescobarh.rs" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/rust/hdescobarh.rs" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/rust/hdescobarh.rs" new file mode 100644 index 0000000000..01ffcf1fa1 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/rust/hdescobarh.rs" @@ -0,0 +1,137 @@ +// author: Hans D. Escobar H. (hdescobarh) +#![crate_name = "triples_pitagoricos"] +#![crate_type = "cdylib"] +use std::cmp::min; + +/// Representa un triple pitagórico. +/// +/// Un triple pitagórico se define como un conjunto de tres números {a, b, c} +/// que satisfacen a² + b² = c², tal que a,b,c ∈ ℤ⁺. +/// Un triple cumple que a > b > c, por lo que se puede anotar como (a,b,c) +#[derive(PartialEq, Eq, Hash, Debug)] +pub struct TriplePitagorico { + cateto_menor: usize, + cateto_mayor: usize, + hipotenusa: usize, +} + +impl TriplePitagorico { + /// Genera todos los triples pitagóricos que satisfacen que su máximo + /// valor es menor o igual a un entero positivo r constante. + /// + /// # Descripción: + /// Como un triple pitagórico satisface que a < b < c, una estrategia sencilla es por cada + /// b < r explorar cada a < b y encontrar los sqrt(a² + b²) enteros menores o iguales a r. + /// Esta implementación además aprovecha que a < sqrt(r² - b²) + 1. + /// + /// El problema es equivalente a, dada una constante constante r ∈ ℤ⁺ y las variables a,b,c ∈ ℤ⁺, + /// encontrar los triples pitagóricos (a,b,c) tales que a² + b² = c² ≤ r². + /// + /// * (1) a, b, c, r ∈ ℤ⁺ (condición) + /// * (2) a² + b² = c² ≤ r² (condición) + /// * (3) 1 ≤ a < b < c ≤ r (por 1 y 2) + /// * (4) a² ≤ r² - b² ⇒ a ≤ sqrt(r² - b²) ⇒ a < sqrt(r² - b²) + 1 (por 2 y 3) + /// * (5) a < min(b, sqrt(r² - b²) + 1) (por 3 y 4) + /// + /// # Argumentos: + /// * `numero` - indica el máximo valor que puede aparecer en los triples pitagóricos generados. + /// + /// # Ejemplo: + /// + /// ``` + /// use triples_pitagoricos::TriplePitagorico; + /// let resultado = TriplePitagorico::desde_numero_maximo(&14).unwrap(); + /// //Retorna los triples (3,4,5), (6,8,10), (5,12,13) + /// println!("{:?}", resultado); + /// + /// ``` + pub fn desde_numero_maximo(numero: &usize) -> Option> { + let mut triples: Vec = Vec::new(); + // Sí (a, b, c) es un triple pitagórico, 2 < a < b < c <= numero + for b in 3..*numero { + let limite_busqueda = min( + b, + ((numero.pow(2) - b.pow(2)) as f64).sqrt().floor() as usize + 1, + ); + for a in 2..limite_busqueda { + // Sí a² + b² son catetos de un triple pitagórico, necesariamente forman un cuadrado perfecto + if let Some(c) = raiz_cuadrada_perfecta(&(a.pow(2) + b.pow(2))) { + triples.push(Self { + cateto_menor: a, + cateto_mayor: b, + hipotenusa: c, + }) + }; + } + } + if triples.is_empty() { + None + } else { + Some(triples) + } + } +} + +/// Retorna la raíz de número sí este es un cuadrado perfecto +fn raiz_cuadrada_perfecta(numero: &usize) -> Option { + let raiz_entera = (*numero as f64).sqrt().floor() as usize; + if raiz_entera.pow(2) == *numero { + Some(raiz_entera) + } else { + None + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::HashSet; + + #[test] + fn no_hay_triple_para_valor() { + let resultado = TriplePitagorico::desde_numero_maximo(&4); + assert_eq!(None, resultado); + } + #[test] + fn genera_triple_y_multiplo() { + let resultado: HashSet = TriplePitagorico::desde_numero_maximo(&10) + .unwrap() + .into_iter() + .collect(); + let esperado: HashSet = [[3, 4, 5], [6, 8, 10]] + .into_iter() + .map(|tripla| TriplePitagorico { + cateto_menor: tripla[0], + cateto_mayor: tripla[1], + hipotenusa: tripla[2], + }) + .collect(); + assert_eq!(esperado, resultado); + } + + #[test] + fn genera_triples_menores_o_iguales() { + let resultado: HashSet = TriplePitagorico::desde_numero_maximo(&25) + .unwrap() + .into_iter() + .collect(); + let esperado: HashSet = [ + [3, 4, 5], + [6, 8, 10], + [5, 12, 13], + [9, 12, 15], + [8, 15, 17], + [12, 16, 20], + [15, 20, 25], + [7, 24, 25], + ] + .into_iter() + .map(|tripla| TriplePitagorico { + cateto_menor: tripla[0], + cateto_mayor: tripla[1], + hipotenusa: tripla[2], + }) + .collect(); + assert_eq!(esperado, resultado); + } +} From fea555e1fbb0a39e7b38a959e3ea07cc21f85169 Mon Sep 17 00:00:00 2001 From: Hugovrc Date: Wed, 4 Oct 2023 18:50:45 -0600 Subject: [PATCH 42/65] Reto #39 - Python --- .../python/Hugovrc.py" | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Hugovrc.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Hugovrc.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Hugovrc.py" new file mode 100644 index 0000000000..5e51f4fba8 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Hugovrc.py" @@ -0,0 +1,11 @@ +def triples_pitagoricos(numero_max: int): + for lado_a in range(1,numero_max+1): + for lado_b in range(lado_a, numero_max+1): + cuadrado_de_a_y_b = lado_a**2 + lado_b**2 + lado_c = int(cuadrado_de_a_y_b ** 0.5) + if lado_c**2 == cuadrado_de_a_y_b and lado_c <= numero_max: + print(f"({lado_a},{lado_b},{lado_c})") + + +triples_pitagoricos(10) +triples_pitagoricos(25) From 462d268d839df0552c1d854448e285dad9c568e3 Mon Sep 17 00:00:00 2001 From: jlcontini Date: Wed, 4 Oct 2023 23:02:10 -0300 Subject: [PATCH 43/65] Reto #01 - primer commit --- .../python/jlcontini.py" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" new file mode 100644 index 0000000000..0cb444855d --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" @@ -0,0 +1,39 @@ +""" +# Reto #1: EL "LENGUAJE HACKER" +#### Dificultad: Fácil | Publicación: 02/01/23 | Corrección: 09/01/23 + +## Enunciado + +``` +/* + * 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") + */ +``` +#### 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)**. +""" + + +def get_string() -> str: + original_string = str(input("Ingresa el texto que quieras transformar a 'lenguaje hacker': ")) + return original_string + + +def transform_string_to_leet(original_string): + + +original_string = get_string() +leet_string = transform_string_to_leet(original_string) +print(leet_string) + + +leet_dictionary: list = {"A": "4", "B": "I3", "C": "[", "D": ")", "E": "3", "F": "|=", "G": "&", "H": "#", "I": "", "J": "", "K": "", "L": "", "M": "", "N": "", "O": "", "P": "", "Q": "", "R": "", "S": "", "T": "", "U": "", "V": "", "W": "", "X": "", "Y": "", "Z": ""} + From 5b541b32e99250f279f72e2bba20c112765b7770 Mon Sep 17 00:00:00 2001 From: Sandy Date: Wed, 4 Oct 2023 22:14:44 -0400 Subject: [PATCH 44/65] #2 - Partido de tennis --- .../javascript/sandybierhoff.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/javascript/sandybierhoff.js diff --git a/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/javascript/sandybierhoff.js b/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/javascript/sandybierhoff.js new file mode 100644 index 0000000000..cd617a212e --- /dev/null +++ b/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/javascript/sandybierhoff.js @@ -0,0 +1,42 @@ +const P1 = "P1"; +const P2 = "P2"; + +function playTenis(...secuence) { + let printScore = function() { + let getValue = function(value) { + const values = { 0: 'Love', 1: '15', 2: '30', 3: '40' }; + if(value in values) return values[value]; + } + + if (score[0] == score[1] && score[0] >= 3) + console.log('Deuce'); + else if (score[0] > score[1] && (score[0] - score[1]) == 1 && score[0] > 3) + console.log('Ventaja P1'); + else if (score[1] > score[0] && (score[1] - score[0]) == 1 && score[1] > 3) + console.log('Ventaja P2'); + else if (score[1] - score[0] > 1 && score[1] > 4) + console.log('Ha ganado el P2'); + else if (score[0] - score[1] > 1 && score[0] > 4) + console.log('Ha ganado el P1'); + else { + console.log(`${getValue(score[0])} - ${getValue(score[1])}`); + } + } + + let score = [0, 0]; + + for (let index = 0; index < secuence.length; index++) { + const element = secuence[index]; + if(element !== P1 && element !== P2) continue; + + if (element.length!=2) continue; + const player = parseInt(element[1]); + if (player!=1 && player!=2) continue; + + score[player-1] += 1; + + printScore(); + } +} + +playTenis('P1', 'P1', 'P2', 'P2', 'P1', 'P2', 'P1', 'P1'); \ No newline at end of file From 7af1f0bab2c3599f2a8dbe6037032cedf7d6a5d4 Mon Sep 17 00:00:00 2001 From: jlcontini Date: Wed, 4 Oct 2023 23:15:11 -0300 Subject: [PATCH 45/65] leet list - Segundo commit --- .../python/jlcontini.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" index 0cb444855d..8a36421dd1 100644 --- "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" @@ -35,5 +35,5 @@ def transform_string_to_leet(original_string): print(leet_string) -leet_dictionary: list = {"A": "4", "B": "I3", "C": "[", "D": ")", "E": "3", "F": "|=", "G": "&", "H": "#", "I": "", "J": "", "K": "", "L": "", "M": "", "N": "", "O": "", "P": "", "Q": "", "R": "", "S": "", "T": "", "U": "", "V": "", "W": "", "X": "", "Y": "", "Z": ""} +leet_dictionary: list = {"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"} From 1d0b579eeaf5a3a180b8bda876659ebcf0898588 Mon Sep 17 00:00:00 2001 From: Javier_Perez <60175453+JavierPerezManzanaro@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:23:26 +0200 Subject: [PATCH 46/65] Add files via upload --- .../python/JavierPerezManzanaro.py" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/JavierPerezManzanaro.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/JavierPerezManzanaro.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/JavierPerezManzanaro.py" new file mode 100644 index 0000000000..8fb2e2d9c2 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/JavierPerezManzanaro.py" @@ -0,0 +1,34 @@ +""" +/* + * Crea una función que encuentre todos los triples pitagóricos + * (ternas) menores o iguales a un número dado. + * - Debes buscar información sobre qué es un triple pitagórico. + * - La función únicamente recibe el número máximo que puede + * aparecer en el triple. + * - Ejemplo: Los triples menores o iguales a 10 están + * formados por (3, 4, 5) y (6, 8, 10). + */ + +""" + + + +def triples_pitagoricos(maximo: int) -> list: + """Triples Pitagóricos son tres números enteros a, b y c que satisfacen la ecuación del teorema de Pitágoras: ( a2 + b2 = c2 ) + + Args: + maximo (int): Numero máximo a anaalizar + + Returns: + list: Lista de los trios pitagóricos + """ + resultado = [] + for a in range(maximo, 0, -1): + for b in range(maximo, 0, -1): + for c in range(maximo, 0, -1): + if pow(a, 2) + pow(b, 2) == pow(c, 2): + print(f'{(a, b, c)}: {pow(a, 2) + pow(b, 2)} ({pow(a, 2)} + {pow(b, 2)}) = {pow(c, 2)}') + resultado.append((a, b, c)) + return resultado + +print(triples_pitagoricos(10)) From 825cfe5f650bb9ea3466a9fbac3e1c25fcc0798f Mon Sep 17 00:00:00 2001 From: KevinED11 Date: Thu, 5 Oct 2023 08:17:56 -0700 Subject: [PATCH 47/65] reto #39 - python --- .../python/KevinED11.py" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/KevinED11.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/KevinED11.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/KevinED11.py" new file mode 100644 index 0000000000..c569da316d --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/KevinED11.py" @@ -0,0 +1,45 @@ +import abc +from typing import TypeAlias +import functools + + +PythagoreanTripleList: TypeAlias = list[tuple[int, int, int]] + + +class PythagoreanCalculator(abc.ABC): + @abc.abstractmethod + def calculate(self, max_number: int) -> PythagoreanTripleList: + pass + + +@functools.lru_cache +def calculate_pythagorean_triples(max_number: int) -> PythagoreanTripleList: + triples = [] + c, m = 0, 2 + while c < max_number: + for n in range(1, m): + a = m * m - n * n + b = 2 * m * n + c = m * m + n * n + if c > max_number: + break + triples += [(a, b, c)] + m += 1 + + return triples + + +class PythagoreanTriplesCalculator(PythagoreanCalculator): + def calculate(self, max_number: int) -> PythagoreanTripleList: + return calculate_pythagorean_triples(max_number=max_number) + + +def main(calculator: PythagoreanCalculator) -> None: + max_number = 10 + result = calculator.calculate(max_number) + print(f"Pythagorean triples up to {max_number}: {result}") + + +if __name__ == "__main__": + calculator = PythagoreanTriplesCalculator() + main(calculator=calculator) From 54f462600fe61ae7d573b99ac4a1ae152c767f65 Mon Sep 17 00:00:00 2001 From: Juan Pablo Patino Lopez Date: Thu, 5 Oct 2023 20:42:33 +0200 Subject: [PATCH 48/65] Juanppdev - Reto #39 - Python --- .../python/Juanppdev.py" | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Juanppdev.py" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Juanppdev.py" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Juanppdev.py" new file mode 100644 index 0000000000..bdb3cdbe39 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/python/Juanppdev.py" @@ -0,0 +1,11 @@ +def triples_pitagoricos(maximo): + resultados = [] + for a in range(1, maximo + 1): + for b in range(a, maximo + 1): + c_cuadrado = a**2 + b**2 + c = int(c_cuadrado**0.5) + if c <= maximo and c_cuadrado == c**2: + resultados.append((a, b, c)) + return resultados + +print(triples_pitagoricos(100)) \ No newline at end of file From 83df1dea080aefcdb77de51753424bcaa384a499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Ramos?= Date: Thu, 5 Oct 2023 15:30:14 -0400 Subject: [PATCH 49/65] Reto #0 - Python --- .../python/CaesaRR19.py" | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/CaesaRR19.py" diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/CaesaRR19.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/CaesaRR19.py" new file mode 100644 index 0000000000..7d04bd9415 --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/CaesaRR19.py" @@ -0,0 +1,9 @@ +''' + * 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". +''' +lista = [print('fizzbuzz') if numero % 15 == 0 else print('fizz') if numero % 3 == 0 else print('buzz') if numero % 5 == 0 else print(numero) for numero in range (1, 101)] From ec3b16b4d53195c41463c450e842565245eb9287 Mon Sep 17 00:00:00 2001 From: jlcontini Date: Thu, 5 Oct 2023 16:53:29 -0300 Subject: [PATCH 50/65] Reto #1 - file jlcontini.py --- .../python/jlcontini.py" | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" index 8a36421dd1..6f502985ad 100644 --- "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" @@ -22,18 +22,33 @@ """ +leet_dict: dict = {"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 change_to_leet(original_string: str) -> str: + leet_string = "" + upper_case_string = original_string.upper() + + for character in upper_case_string: + if character in leet_dict: + leet_string += leet_dict[character] + else: + leet_string += character + + return leet_string + + def get_string() -> str: original_string = str(input("Ingresa el texto que quieras transformar a 'lenguaje hacker': ")) return original_string -def transform_string_to_leet(original_string): - - -original_string = get_string() -leet_string = transform_string_to_leet(original_string) -print(leet_string) +def main(): + original_string = get_string() + leet_string = change_to_leet(original_string) + print(leet_string) -leet_dictionary: list = {"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"} +if __name__ == "__main__": + main() \ No newline at end of file From 1d35c6dbe64b9d74b5734aa41d5a83d78cc1a3f9 Mon Sep 17 00:00:00 2001 From: jlcontini Date: Thu, 5 Oct 2023 16:57:22 -0300 Subject: [PATCH 51/65] Reto #01 - archivo jlcontini.py - actualizacion espacio final. --- .../python/jlcontini.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" index 6f502985ad..fb096f2b12 100644 --- "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" @@ -51,4 +51,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() From 60f409d9c3df76a8f1021d137a239fb1e0e71d49 Mon Sep 17 00:00:00 2001 From: jlcontini Date: Thu, 5 Oct 2023 17:35:12 -0300 Subject: [PATCH 52/65] Reto #01 - file jlcontini.py - modificacion --- .../python/jlcontini.py" | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" index fb096f2b12..f1d996de49 100644 --- "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/jlcontini.py" @@ -1,31 +1,12 @@ -""" -# Reto #1: EL "LENGUAJE HACKER" -#### Dificultad: Fácil | Publicación: 02/01/23 | Corrección: 09/01/23 - -## Enunciado - -``` -/* - * 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") - */ -``` -#### 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)**. -""" - - -leet_dict: dict = {"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"} - +# Reto #1 - Leet translator def change_to_leet(original_string: str) -> str: + + leet_dict: dict = {"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"} + leet_string = "" upper_case_string = original_string.upper() @@ -39,14 +20,30 @@ def change_to_leet(original_string: str) -> str: def get_string() -> str: - original_string = str(input("Ingresa el texto que quieras transformar a 'lenguaje hacker': ")) + original_string = str(input("Ingresa el texto que quieras transformar a 'lenguaje hacker': \n")) return original_string +def show_results(original_string, leet_string): + print(f""" + Texto original ingresado: + {original_string} + + Texto en formato leet: + {leet_string} + + """) + + def main(): + print("\n\nLEET: esto es una prueba") + print(change_to_leet("LEET: esto es una prueba\n\n")) + original_string = get_string() leet_string = change_to_leet(original_string) - print(leet_string) + show_results(original_string, leet_string) + + print(f'\nResultado de la transformacion: \n{leet_string}\n') From c7e17bc830719d8a6f842980c7e3e2555f36525f Mon Sep 17 00:00:00 2001 From: Ricardo Alfaro Date: Thu, 5 Oct 2023 16:35:38 -0600 Subject: [PATCH 53/65] Reto #1 - Java --- .../java/rearalf.java" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/rearalf.java" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/rearalf.java" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/rearalf.java" new file mode 100644 index 0000000000..e69de29bb2 From d184cc9ab50cd4fe67b20a61116f0502c5f70c72 Mon Sep 17 00:00:00 2001 From: FabianTorres Date: Thu, 5 Oct 2023 17:48:50 -0500 Subject: [PATCH 54/65] New Solution: Reto #2 - Python --- .../python/nftorres.py | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/python/nftorres.py diff --git a/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/python/nftorres.py b/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/python/nftorres.py new file mode 100644 index 0000000000..18215ea63b --- /dev/null +++ b/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/python/nftorres.py @@ -0,0 +1,93 @@ +class TenisGame: + """This class represents a tennis game between the players P1 and P2.""" + + def __init__(self) -> None: + """This method initializes an instance with the default attributes""" + self.game_status: bool = False + self.game_score: str = None + self.player1_name: str = None + self.player1_score: int = None + self.player2_name: str = None + self.player2_score: int = None + + def identify_players(self, sequence: list) -> list: + """This method identifies the players in the game. + + Args: + sequence (list): sequence of player scores + + Returns: + list: players in the game + """ + self.sequence = sequence + self.players = list(set(self.sequence)) + return self.players + + def validate_players(self, players: list) -> bool: + """This method validates that the players in the sequence are P1 and P2 + + Args: + players (list): players identified by the identify_players method + + Returns: + bool: True is returned if the players identified are P1 and P2. otherwise, False is returned. + """ + if len(players) == 2 and "P1" in players and "P2" in players: + self.player1_name, self.player2_name = "P1", "P2" + return True + return False + + def start_game(self) -> None: + """This method initializes the player scores and the game status.""" + self.game_status = True + self.player1_score = 0 + self.player2_score = 0 + + def update_game_score(self, scorer: str) -> None: + """This method updates the player scores and the game score. + + Args: + scorer (str): player who scored point + """ + self.POINTS = ["Love", 15, 30, 40] + + self.player1_score += 1 if scorer == self.player1_name else 0 + self.player2_score += 1 if scorer == self.player2_name else 0 + + if self.player1_score >= 3 and self.player2_score >= 3: + if self.game_status and abs(self.player1_score - self.player2_score) <= 1: + self.game_score = ( + "Deuce" + if self.player1_score == self.player2_score + else "Ventaja P1" + if self.player1_score > self.player2_score + else "Ventaja P2" + ) + else: + self.game_status = False + self.game_score = ( + "Ha ganado el P1" + if self.player1_score > self.player2_score + else "Ha ganado el P2" + ) + else: + if self.player1_score < 4 and self.player2_score < 4: + self.game_score = f"{self.POINTS[self.player1_score]} - {self.POINTS[self.player2_score]}" + else: + self.game_status = False + + +if __name__ == "__main__": + sequence = ["P1", "P1", "P2", "P2", "P1", "P2", "P1", "P1"] + tenis_game = TenisGame() + players = tenis_game.identify_players(sequence) + + if tenis_game.validate_players(players): + tenis_game.start_game() + for scorer in sequence: + tenis_game.update_game_score(scorer) + print(tenis_game.game_score) + else: + print( + "No fue posible iniciar el juego. Sólo pueden jugar dos jugadores: P1 y P2." + ) From af9a9ea616b4c9fa867e40f989b405911d17778b Mon Sep 17 00:00:00 2001 From: ViankaMB Date: Thu, 5 Oct 2023 20:01:45 -0400 Subject: [PATCH 55/65] Reto #0 - Java --- .../java/ViankaMB.java" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/java/ViankaMB.java" diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/java/ViankaMB.java" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/java/ViankaMB.java" new file mode 100644 index 0000000000..ec6784983e --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/java/ViankaMB.java" @@ -0,0 +1,18 @@ +public class ViankaMB { + + public static void main(String[] args) { + for (int x = 1; x <= 100; x++) { + + if (x % 3 == 0 & x % 5 == 0) { + System.out.println("fizzbuzz"); + } else if (x % 3 == 0) { + System.out.println("fizz"); + } else if (x % 5 == 0) { + System.out.println("buzz"); + } else { + System.out.println(x); + } + } + } + +} \ No newline at end of file From a547114a694c88aa53e375f17367b9ab88d3ba0b Mon Sep 17 00:00:00 2001 From: Ricardo Alfaro Date: Thu, 5 Oct 2023 21:30:02 -0600 Subject: [PATCH 56/65] Reto #1 - Java --- .../java/rearalf.java" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/rearalf.java" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/rearalf.java" index e69de29bb2..8073d1b02a 100644 --- "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/rearalf.java" +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/rearalf.java" @@ -0,0 +1,45 @@ +import java.io.InputStream; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + InputStream steam = System.in; + Scanner scanner = new Scanner(steam); + System.out.print("Enter the text: "); + String input = scanner.next(); + String resultConvert = convertTextToLeet(input.toUpperCase()); + System.out.print(resultConvert); + } + + public static String convertTextToLeet(String text){ + text = text.replaceAll("A" ,"4"); + text = text.replaceAll("B", "|3"); + text = text.replaceAll("C", "["); + text = text.replaceAll("D", "|)"); + text = text.replaceAll("E", "3"); + text = text.replaceAll("F", "ph"); + text = text.replaceAll("G", "6"); + text = text.replaceAll("H", "#"); + text = text.replaceAll("I", "1"); + text = text.replaceAll("J", "]"); + text = text.replaceAll("K", "|<"); + text = text.replaceAll("L", "1"); + text = text.replaceAll("M", "|V|"); + text = text.replaceAll("N", "И"); + text = text.replaceAll("Ñ", "И~"); + text = text.replaceAll("O", "0"); + text = text.replaceAll("P", "|>"); + text = text.replaceAll("Q", "0_"); + text = text.replaceAll("R", "|2"); + text = text.replaceAll("S", "5"); + text = text.replaceAll("T", "7"); + text = text.replaceAll("U", "(_)"); + text = text.replaceAll("V", "|/"); + text = text.replaceAll("W", "uu"); + text = text.replaceAll("X", "><"); + text = text.replaceAll("Y", "j"); + text = text.replaceAll("Z", "2"); + text = text.replaceAll(" ", " "); + return text; + } +} \ No newline at end of file From 1b0817b0294e81c467e47485f97f744b42ca4416 Mon Sep 17 00:00:00 2001 From: Sergio de Santiago <147100454+sdesantiago@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:23:26 +0200 Subject: [PATCH 57/65] Reto #39 - Java --- .../java/Sdesantiago.java" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/Sdesantiago.java" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/Sdesantiago.java" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/Sdesantiago.java" new file mode 100644 index 0000000000..e32775dd40 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/Sdesantiago.java" @@ -0,0 +1,36 @@ +/* + Crea una función que encuentre todos los triples pitagóricos + (ternas) menores o iguales a un número dado. + - Debes buscar información sobre qué es un triple pitagórico. + - La función únicamente recibe el número máximo que puede + aparecer en el triple. + - Ejemplo: Los triples menores o iguales a 10 están + formados por (3, 4, 5) y (6, 8, 10). + +* Triple pitagórico -> a² = b² + c² +*/ + +import java.util.Scanner; + +public class Sdesantiago { + public static void main(String[] args) { + int entrada; + + Scanner scan = new Scanner(System.in); + System.out.print("RETO 39 BY MOUREDEV\n- Ingresa un número positivo para comenzar: "); + entrada = scan.nextInt(); + scan.close(); + if (entrada<=0) { + System.err.print("ERROR: El valor ingresado no es válido. Finalizando ejecución del programa."); + return; + } + for (int a=entrada;a>0;a--){ + for (int b=a-1;b>0;b--){ + for (int c=b;c>0;c--){ + if (Math.pow(a,2)==Math.pow(b,2)+Math.pow(c,2)) + System.out.println("("+a+","+b+","+c+")"); + } + } + } + } +} \ No newline at end of file From 808e7d312ea7c067eaa8e165bf55348fa892d585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20L=C3=B3pez=20Ariza?= <52292080+DiegoSHS@users.noreply.github.com> Date: Fri, 6 Oct 2023 02:46:09 -0600 Subject: [PATCH 58/65] reto 0 y 1 --- .../javascript/DiegoSHS.js" | 20 +++++++ .../javascript/DiegoSHS.js" | 59 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/DiegoSHS.js" create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/DiegoSHS.js" diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/DiegoSHS.js" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/DiegoSHS.js" new file mode 100644 index 0000000000..d73af5229b --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/javascript/DiegoSHS.js" @@ -0,0 +1,20 @@ +/** + * Imprimer los numeros desde un numero inicial que se le proporcione hasta un numero final, reemplazando los siguientes numeros: + * - 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" + * @param {Number} init Número del que se iniciará + * @param {Number} limit Número en donde se detendrá la iteración + */ +const fizzbuzz = (init = 0, limit = 100) => { + let text = '' + while (init < limit) { + init++ + text = + (init % 15 === 0) ? `fizzbuzz` : + (init % 3 === 0) ? `fizz` : + (init % 5 === 0) ? `buzz` : init + console.log(text) + } +} +fizzbuzz() \ No newline at end of file diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/DiegoSHS.js" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/DiegoSHS.js" new file mode 100644 index 0000000000..aa683b68f6 --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/javascript/DiegoSHS.js" @@ -0,0 +1,59 @@ +const texto = `El fichero de código` +/** + * Transforma un normal a lenguaje hacker + * @param {String} text + */ +const hackerTranslator = (text) => { + const datamap = { + "a": '4', + "b": 'ß', + "c": '©', + "d": 'cl', + "e": '€', + "f": 'ƒ', + "g": '6', + "h": '#', + "i": '!', + "j": ']', + "k": '|c', + "l": '£', + "m": 'nn', + "n": 'И', + "o": '0', + "p": '|º', + "q": '&', + "r": 'Я', + "s": '$', + "t": '7', + "u": 'บ', + "v": '\/', + "w": 'Ш', + "x": 'Ж', + "y": 'Ч', + "z": '2', + "1": "L", + "2": "R", + "3": "E", + "4": "A", + "5": "S", + "6": "b", + "7": "T", + "8": "B", + "9": "g", + "0": "o", + " ": " " + } + const result = text.toLowerCase().split('').map(e => datamap[e]).join('') + return result +} +/** + * Transforma un normal a lenguaje hacker con expresiones regulares + * @param {String} text + */ +const Translator = (text) => { + const datamap = [[/0/gi, "o"], [/1/gi, "L"], [/2/gi, "R"], [/3/gi, "E"], [/4/gi, "A"], [/5/gi, "S"], [/6/gi, "b"], [/7/gi, "T"], [/8/gi, "B"], [/9/gi, "g"], [/a/gi, "4"], [/b/gi, "ß"], [/c/gi, "©"], [/d/gi, "cl"], [/e/gi, "€"], [/f/gi, "ƒ"], [/g/gi, "6"], [/h/gi, "#"], [/i/gi, "!"], [/j/gi, "]"], [/k/gi, "|c"], [/l/gi, "£"], [/m/gi, "nn"], [/n/gi, "И"], [/o/gi, "0"], [/p/gi, "|º"], [/q/gi, "&"], [/r/gi, "Я"], [/s/gi, "$"], [/t/gi, "7"], [/u/gi, "บ"], [/v/gi, '\/'], [/w/gi, "Ш"], [/x/gi, "Ж"], [/y/gi, "Ч"], [/z/gi, "2"], [/ /gi, " "]] + datamap.forEach(e => text = text.replace(...e)) + return text +} + +console.log(hackerTranslator(texto)) \ No newline at end of file From 5380cbf8c4a985a9905c6e2044c7537555537582 Mon Sep 17 00:00:00 2001 From: joaquinferrero Date: Fri, 6 Oct 2023 15:49:06 +0200 Subject: [PATCH 59/65] Reto #39 - Perl --- .../perl/joaquinferrero.pl" | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/perl/joaquinferrero.pl" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/perl/joaquinferrero.pl" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/perl/joaquinferrero.pl" new file mode 100644 index 0000000000..10829b5524 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/perl/joaquinferrero.pl" @@ -0,0 +1,112 @@ +#!/usr/bin/env perl +# +# Terna pitagórica +# +# Crea una función que encuentre todos las ternas pitagóricas +# menores o iguales a un número dado. +# +# - Una terna pitagórica es un conjunto ordenado de tres números enteros positivos +# a, b, c, y son solución de la ecuación diofántica cuadrática +# a² + b² = c² +# - La función recibe el número máximo que puede aparecer en la terna. +# +# Ejemplo: +# Las ternas menores o iguales a 10 son (3, 4, 5) y (6, 8, 10). +# +# Joaquín Ferrero, 20231005 +# +use v5.38; +#use strict; # activo desde Perl v5.12 +#use warnings; # activo desde Perl v5.35 +use utf8; # desde Perl v5.8 +use open IO => qw(:utf8 :std); + +my @ternas = ternas(100); + +for my $terna (@ternas) { + my($a, $b, $c) = $terna->@*; # desde Perl v5.20 + + say "($a, $b, $c):\t", $a**2, " + ", $b**2, " = ", $c**2; +} +say "Total ", scalar(@ternas), " ternas"; + + +sub ternas($máximo) { # desde Perl v5.36 + my @ternas; + my %ternas_vistas; + + # Búsqueda exhaustiva, de todas las combinaciones + for my $m ( 1 .. $máximo ) { + for my $n ( $m .. $máximo ) { + next if $ternas_vistas{"$m;$n"}; # sólo ternas únicas + + my $o = sqrt($m**2 + $n**2); + + next if $o > $máximo; # fuera del límite + next if int($o) != $o; # no es terna + + # generación de ternas no primitivas + for my $d (1 .. $máximo) { + my $m2 = $d * $m; + my $n2 = $d * $n; + my $o2 = $d * $o; + last if $o2 > $máximo or $m2 > $máximo or $n2 > $máximo; + + push @ternas, [ $m2, $n2, $o2 ]; + + $ternas_vistas{"$m2;$n2"}++; + } + } + } + + return @ternas; +} + +__END__ +@ternas = ternas_pitagóricas(100); +@ternas = ternas_pitagóricas_pitagóras(100); + +sub ternas_pitagóricas_pitagóras($máximo) { + my @ternas; + + # Método de Pitágoras + # a = j²-1 + # b = 2j + # c = j²+1 + # siendo j>0 + + for my $j (1..$máximo) { + my $a = $j**2 -1; + my $b = 2*$j; + my $c = $j**2 +1; + last if $a > $máximo or $b > $máximo or $c > $máximo; + + push @ternas, [ $a, $b, $c ]; + } + + return @ternas; +} + +sub ternas_pitagóricas($máximo) { + my @ternas; + + # Método babilónico + # a = m²-n² + # b = 2mn + # c = m²+n², + # siendo m>n + + # Doble bucle para los valores de m y n + for my $n ( 1 .. $máximo-1 ) { + for my $m ( $n+1 .. $máximo ) { + my $a = $m**2 - $n**2; + my $b = 2*$m*$n; + my $c = $m**2 + $n**2; + next if $a > $máximo or $b > $máximo or $c > $máximo; + push @ternas, [ $a, $b, $c ]; + } + } + + return @ternas; +} + From e030a1c79576437c6fa2fa98c9bf93db3aaf2bc7 Mon Sep 17 00:00:00 2001 From: joaquinferrero Date: Fri, 6 Oct 2023 15:50:02 +0200 Subject: [PATCH 60/65] Reto #39 - Raku --- .../raku/joaquinferrero.raku" | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/raku/joaquinferrero.raku" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/raku/joaquinferrero.raku" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/raku/joaquinferrero.raku" new file mode 100644 index 0000000000..6930dc87f2 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/raku/joaquinferrero.raku" @@ -0,0 +1,89 @@ +#!/usr/bin/env raku +# +# Terna pitagórica +# +# Crea una función que encuentre todos las ternas pitagóricas +# menores o iguales a un número dado. +# +# - Una terna pitagórica es un conjunto ordenado de tres números enteros positivos +# a, b, c, y son solución de la ecuación diofántica cuadrática +# a² + b² = c² +# - La función recibe el número máximo que puede aparecer en la terna. +# +# Ejemplo: +# Las ternas menores o iguales a 10 son (3, 4, 5) y (6, 8, 10). +# +# Joaquín Ferrero, 20231005 +# +use v6; + + +my @ternas = ternas(100); + +for @ternas -> @terna { + my ($a, $b, $c) = @terna; + + say "($a, $b, $c):\t", $a², " + ", $b², " = ", $c²; +} +say "Total ", @ternas.elems, " ternas"; + +sub ternas($máximo) { + my %ternas_vistas; + + # Búsqueda exhaustiva, de todas las combinaciones + my @ternas = gather { + for 1 .. $máximo -> $m { + for $m .. $máximo -> $n { + next if %ternas_vistas{"$m;$n"}; # sólo ternas únicas + + my $o = ($m² + $n²).sqrt; + + next if $o > $máximo; # fuera del límite + next if $o.Int != $o; # no es terna + + # generación de ternas no primitivas + for 1 .. $máximo -> $d { + my $m2 = $d * $m; + my $n2 = $d * $n; + my $o2 = $d * $o; + last if $o2 > $máximo or $m2 > $máximo or $n2 > $máximo; + + take [ $m2, $n2, $o2 ]; + + %ternas_vistas{"$m2;$n2"}++; + } + } + } + } + + return @ternas; +} + +=finish + +sub ternas_pitagóricas_babilónicas($máximo) { + + # Método babilónico + # a = m²-n² + # b = 2mn + # c = m²+n² + # siendo m>n + + # Doble bucle para los valores de m y n + my @ternas = gather { + for 1 ..^ $máximo -> $n { + for $n ^.. $máximo -> $m { + my $a = $m² - $n²; + my $b = 2 × $m × $n; + my $c = $m² + $n²; + + next if $a > $máximo or $b > $máximo or $c > $máximo; + + take [ $a, $b, $c ]; + } + } + } + + return @ternas; +} + From 9ebe985876831c4748961af263f545a65d510b46 Mon Sep 17 00:00:00 2001 From: Noe <33688112+noehum7@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:30:24 +0200 Subject: [PATCH 61/65] Reto #39 - Java --- .../java/noehum7.java" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/noehum7.java" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/noehum7.java" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/noehum7.java" new file mode 100644 index 0000000000..a3b3d44b76 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/noehum7.java" @@ -0,0 +1,23 @@ +public class TriplesPitagoricos { + public static void main(String[] args) { + List> resultado = triplesPitagoricos(10); + resultado.forEach(System.out::println); + } + + private static List> triplesPitagoricos(int n) { + List> triples = new ArrayList<>(); + for (int i = 1; i <= n; i++) { + for (int j = i; j < n; j++) { + int z = (int) Math.sqrt(i * i + j * j); + if (z <= n && i * i + j * j == z * z) { + List triple = new ArrayList<>(); + triple.add(i); + triple.add(j); + triple.add(z); + triples.add(triple); + } + } + } + return triples; + } +} From ef977e03e8078e651fd171b2f926a8926b2e9735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa=20Bernabeu?= Date: Fri, 6 Oct 2023 18:39:37 +0200 Subject: [PATCH 62/65] Reto #9 - Python --- .../python/Bombkid85.py" | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "Retos/Reto #9 - HETEROGRAMA, ISOGRAMA Y PANGRAMA [F\303\241cil]/python/Bombkid85.py" diff --git "a/Retos/Reto #9 - HETEROGRAMA, ISOGRAMA Y PANGRAMA [F\303\241cil]/python/Bombkid85.py" "b/Retos/Reto #9 - HETEROGRAMA, ISOGRAMA Y PANGRAMA [F\303\241cil]/python/Bombkid85.py" new file mode 100644 index 0000000000..586e62a374 --- /dev/null +++ "b/Retos/Reto #9 - HETEROGRAMA, ISOGRAMA Y PANGRAMA [F\303\241cil]/python/Bombkid85.py" @@ -0,0 +1,52 @@ +import math + +abc = ["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"] + +def heterograma(phrase): + phrase = phrase.lower() + for letter in phrase: + if letter in abc: + count = 0 + for letter_compare in phrase: + if letter_compare == letter: + count = count + 1 + if count > 1: + return "No es un heterograma" + return "Es un heterograma" + +def isograma(phrase): + phrase = phrase.lower() + letters_count = set({}) + for letter in phrase: + if letter in abc: + count = 0 + for letter_compare in phrase: + if letter_compare == letter: + count = count + 1 + letters_count.add(count) + if len(letters_count) > 1: + return "No es un isograma" + elif max(letters_count) == 1: + return "No es un isograma" + else: + return "Es un isograma" + +def pangrama(phrase): + phrase = phrase.lower() + letters_list = [] + for letter in phrase: + if letter in abc and letter not in letters_list: + letters_list.append(letter) + if len(letters_list) == len(abc): + return "Es un pangrama" + else: + return "No es un pangrama" + + +print(heterograma("Hola que haces")) +print(heterograma("Trueno a mil")) +print(isograma("Trueno a mil")) +print(isograma("Hola que haces")) +print(isograma("Bebe")) +print(pangrama("Hola que haces")) +print(pangrama("Benjamín pidió una bebida de kiwi y fresa. Noé, sin vergüenza, la más exquisita champaña del menú.")) \ No newline at end of file From 0f535c773747bc2ddd1c1cf083617d1b5eb6c80b Mon Sep 17 00:00:00 2001 From: Miguel Millones Date: Fri, 6 Oct 2023 13:19:16 -0500 Subject: [PATCH 63/65] Reto #11 - Python --- .../python/miguelmillones.py" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/miguelmillones.py" diff --git "a/Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/miguelmillones.py" "b/Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/miguelmillones.py" new file mode 100644 index 0000000000..99cff70939 --- /dev/null +++ "b/Retos/Reto #11 - URL PARAMS [F\303\241cil]/python/miguelmillones.py" @@ -0,0 +1,28 @@ +'''Dada una URL con parámetros, crea una función que obtenga sus valores. +No se pueden usar operaciones del lenguaje que realicen esta tarea directamente. + * + * Ejemplo: En la url https://retosdeprogramacion.com?year=2023&challenge=0 + * los parámetros serían ["2023", "0"] +''' +VALUES=[] + +def url_parameter(url): + value='' + point=[] + tamano=len(url) + P=0 + while P Date: Fri, 6 Oct 2023 21:02:02 +0200 Subject: [PATCH 64/65] Reto #39 - Java --- .../java/DevJonRamos.java" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/DevJonRamos.java" diff --git "a/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/DevJonRamos.java" "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/DevJonRamos.java" new file mode 100644 index 0000000000..f76f407168 --- /dev/null +++ "b/Retos/Reto #39 - TRIPLES PITAG\303\223RICOS [Media]/java/DevJonRamos.java" @@ -0,0 +1,38 @@ +import java.util.ArrayList; +import java.util.List; + +public class DevJonRamos { + + public static List> triplesPitagoricos(int limite){ + + int m = 2; + List> ternas = new ArrayList<>(); + + while (true) { + + for (int n = 1; n < m; n++) { + + int a = (m * m) - (n * n); + int b = 2 * m * n; + int c = (m * m) + (n * n); + + if(c > limite) return ternas; + + ternas.add(List.of(a, b, c)); + + } + + m++; + + } + + } + + public static void main(String[] args) throws Exception { + + int limite = 50; + + System.out.println(triplesPitagoricos(limite)); + + } +} From 8277a951335f6b60f2d68fa41ade4e52f6de4f4e Mon Sep 17 00:00:00 2001 From: Oscar Hernandez Date: Fri, 6 Oct 2023 14:54:21 -0600 Subject: [PATCH 65/65] Solucion reto #0 --- .../go/ozkar503.go" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/go/ozkar503.go" diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/go/ozkar503.go" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/go/ozkar503.go" new file mode 100644 index 0000000000..9500704e06 --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/go/ozkar503.go" @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "strconv" +) + +/* + * 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". + */ +func main() { + for i := 1; i <= 100; i++ { + if i%3 == 0 && i%5 == 0 { + fmt.Println(strconv.Itoa(i) + " fizzbuzz") + } else if i%3 == 0 { + fmt.Println(strconv.Itoa(i) + " fizz") + } else if i%5 == 0 { + fmt.Println(strconv.Itoa(i) + " buzz") + } else { + fmt.Println(strconv.Itoa(i) + " ---") + } + } +}