-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/espinoleandroo/retos-progra…
- Loading branch information
Showing
189 changed files
with
13,965 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/javascript/BRivasTorres.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const fizzBuzz = () => { | ||
for (let i = 0; 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"); | ||
} | ||
} | ||
}; | ||
|
||
console.log(fizzBuzz()); |
16 changes: 16 additions & 0 deletions
16
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/javascript/ifritzler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const MIN = 1 | ||
const MAX = 100 | ||
|
||
function isMultiplo(number, targets = []) { | ||
if(number == null) return false | ||
if(!Array.isArray(targets)) targets = [targets] | ||
|
||
return targets.every(target => number % target === 0) | ||
} | ||
|
||
for(let i = MIN; i <= MAX; i++) { | ||
if(isMultiplo(i, [3, 5])) console.log('fizzbuzz') | ||
else if(isMultiplo(i, 3)) console.log('fizz') | ||
else if(isMultiplo(i, 5)) console.log('buzz') | ||
else console.log(i) | ||
} |
31 changes: 31 additions & 0 deletions
31
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/javascript/rodrigosambadesaa.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fizzbuzz = numVal => { | ||
if (typeof numVal !== 'number') { | ||
throw new Error(`"${numVal}" is not a number`) | ||
} | ||
|
||
if (numVal === 0) { | ||
return numVal | ||
} | ||
|
||
if (numVal % 3 === 0 && numVal % 5 === 0) { | ||
return 'fizzbuzz' | ||
} | ||
|
||
if (numVal % 3 === 0) { | ||
return 'fizz' | ||
} | ||
|
||
if (numVal % 5 === 0) { | ||
return 'buzz' | ||
} | ||
|
||
return numVal | ||
} | ||
|
||
const printFizzbuzz = number => { | ||
for (let i = 1; i <= number; i++) { | ||
console.log(`${fizzbuzz(i)}`) | ||
} | ||
} | ||
|
||
printFizzbuzz(100) |
9 changes: 9 additions & 0 deletions
9
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/python/JuanPaperez.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
for i in range(1,101): | ||
if i%3 == 0 and i%5 == 0: | ||
print("fizz buzz") | ||
elif i%3 == 0: | ||
print("fizz") | ||
elif i%5 == 0: | ||
print("buzz") | ||
else: | ||
print(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/python/mariovelascodev.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def fizz_buzz(): | ||
for number in range(1,101): | ||
if number % 3 == 0 and number % 5 == 0: | ||
print("fizzbuzz") | ||
elif number % 3 == 0: | ||
print("fizz") | ||
elif number % 5 == 0: | ||
print("buzz") | ||
else: | ||
print(number) | ||
|
||
fizz_buzz() |
20 changes: 20 additions & 0 deletions
20
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/python/n4nd1k4nde.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
''' | ||
/* | ||
* 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". | ||
*/ | ||
''' | ||
|
||
for i in range(1, 101): | ||
if i % 3 and i % 5 == 0: | ||
print("fizzbuzz") | ||
elif i % 5 == 0: | ||
print("buzz") | ||
elif i % 3 == 0: | ||
print("fizz") | ||
else: | ||
print(i) |
11 changes: 11 additions & 0 deletions
11
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/typescript/andeveling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const fizzBuzz = (limit: number): void => { | ||
const numbers = Array.from({ length: limit }, (_, index) => index + 1) | ||
for (const number of numbers) { | ||
if (number % 3 === 0) console.log("fizz") | ||
if (number % 5 === 0) console.log("buzz") | ||
if (number % 3 === 0 && number % 5 === 0) console.log("fizzbuzz") | ||
else console.log(number) | ||
} | ||
} | ||
|
||
fizzBuzz(100) |
50 changes: 50 additions & 0 deletions
50
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/javascript/BRivasTorres.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const leetAlphabet = { | ||
a: "4", | ||
b: "13", | ||
c: "[", | ||
d: ")", | ||
e: "3", | ||
f: "|=", | ||
g: "&", | ||
h: "#", | ||
i: "1", | ||
j: ",_|", | ||
k: ">|", | ||
l: "1", | ||
m: "|/|", | ||
n: "^/", | ||
o: "0", | ||
p: "|*", | ||
q: "(_,)", | ||
r: "|2", | ||
s: "5", | ||
t: "7", | ||
u: "(_)", | ||
v: "/", | ||
w: "//", | ||
x: "><", | ||
y: "`j", | ||
z: "2", | ||
1: "L", | ||
2: "R", | ||
3: "E", | ||
4: "A", | ||
5: "S", | ||
6: "b", | ||
7: "T", | ||
8: "B", | ||
9: "g", | ||
0: "o", | ||
}; | ||
|
||
const lenguajeHacker = (s) => { | ||
let r = ""; | ||
for (let char of s.toLowerCase()) { | ||
let isChar = leetAlphabet[char]; | ||
isChar ? (r += isChar) : (r += char); | ||
} | ||
return r; | ||
}; | ||
|
||
console.log(lenguajeHacker("Reto mouredev #4")); | ||
console.log(lenguajeHacker("Hola Mundo")); |
64 changes: 64 additions & 0 deletions
64
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/javascript/aran-tm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
const LOWER_CASE_LETTERS = | ||
['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']; | ||
|
||
const UPPER_CASE_LETTERS = | ||
['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']; | ||
|
||
const LEET_SPEAK_ALPHABET = | ||
['4', 'I3', '[', ')', '3', '|=', '&', '#', '1', ',_|', '>|', '1', 'IVI', | ||
'^/', '0', '|*', '(_,)', 'I2', '5', '7', '(_)', '\/', '\/\/', '><', 'j', '2'] | ||
|
||
const LEET_NUMBERS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
const NUMBERS_TO_LEET = ['()', 'L', 'R', 'E', 'A', 'S', 'b', 'T', 'B', 'g']; | ||
|
||
function convert_to_leet_alphabet(){ | ||
|
||
// get the string | ||
let stringFromUser = prompt("Please enter an entry"); | ||
let string_hacked = []; | ||
|
||
// convert to an array | ||
let arrayFromString = stringFromUser.split(""); | ||
|
||
// using a foreach to compare each character with each array element | ||
arrayFromString.forEach(element => { | ||
|
||
let indexOfLetters; | ||
let indexOfNumbers; | ||
|
||
// to check if it's a lower case letter | ||
if (LOWER_CASE_LETTERS.includes(element)) { | ||
|
||
indexOfLetters = LOWER_CASE_LETTERS.indexOf(element); | ||
string_hacked.push(LEET_SPEAK_ALPHABET[indexOfLetters]); | ||
} | ||
|
||
// to check if it's a upper case letter | ||
else if (UPPER_CASE_LETTERS.includes(element)) { | ||
|
||
indexOfLetters = UPPER_CASE_LETTERS.indexOf(element); | ||
string_hacked.push(LEET_SPEAK_ALPHABET[indexOfLetters]); | ||
} | ||
|
||
// To check if it's a number | ||
else if (LEET_NUMBERS.includes(Number(element))) { | ||
|
||
indexOfNumbers = LEET_NUMBERS.indexOf(Number(element)); | ||
string_hacked.push(NUMBERS_TO_LEET[indexOfNumbers]); | ||
} | ||
|
||
// to identify if there is a space | ||
else if (element == "") { | ||
|
||
string_hacked.push(" "); | ||
} | ||
}); | ||
|
||
console.log(string_hacked); | ||
} | ||
|
||
// calling the function | ||
convert_to_leet_alphabet(); |
89 changes: 89 additions & 0 deletions
89
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/php/julianpk19961.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
/** | ||
* Reto #1: EL "LENGUAJE HACKER" | ||
* 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") | ||
*/ | ||
|
||
|
||
$transform = [ | ||
"a" => "4", | ||
"b" => "I3", | ||
"c" => "[", | ||
"d" => ")", | ||
"e" => "3", | ||
"f" => "|=", | ||
"g" => "&", | ||
"h" => "#", | ||
"i" => "1", | ||
"j" => ",_|", | ||
"k" => ">|", | ||
"l" => "1", | ||
"m" => "/\/\'", | ||
"n" => "^/", | ||
"ñ" => "~", | ||
"o" => "0", | ||
"p" => "|*", | ||
"q" => "(_,)", | ||
"r" => "|2", | ||
"s" => "5", | ||
"t" => "7", | ||
"u" => "(_)", | ||
"v" => "\/", | ||
"w" => "\/\/", | ||
"x" => "><", | ||
"y" => "j", | ||
"z" => "2", | ||
"0" => "o", | ||
"1" => "L", | ||
"2" => "R", | ||
"3" => "E", | ||
"4" => "A", | ||
"5" => "S", | ||
"6" => "b", | ||
"7" => "T", | ||
"8" => "B", | ||
"9" => "g", | ||
]; | ||
|
||
$exceptionsChar = [" ", ".", ",", "'"]; | ||
|
||
function sentencesToLeet($sentence = 'Sentence is void') | ||
{ | ||
|
||
global $transform, $exceptionsChar; | ||
|
||
if (gettype($sentence) === 'object') { | ||
$sentence = "I Can't work with a object, sorry"; | ||
} | ||
|
||
if (gettype($sentence) === 'array') { | ||
$sentence = implode($sentence); | ||
} | ||
|
||
$leetSentences = str_split(strtolower($sentence)); | ||
|
||
foreach ($leetSentences as $character) { | ||
$key = str_replace($exceptionsChar, "", $character); | ||
if ($key) { | ||
echo $transform[$key]; | ||
} else { | ||
echo $character; | ||
} | ||
}; | ||
echo "\n"; | ||
} | ||
|
||
|
||
sentencesToLeet(new stdClass); | ||
sentencesToLeet(["this", "an", "array"]); | ||
sentencesToLeet(25660); | ||
sentencesToLeet(25, 5); | ||
sentencesToLeet(25.5); | ||
sentencesToLeet("Hello"); |
30 changes: 30 additions & 0 deletions
30
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/python/DanniRodrJ.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
''' | ||
Escribe un programa que reciba un texto y transforme lenguaje natural a | ||
"lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje | ||
se caracteriza por sustituir caracteres alfanuméricos. | ||
- Utiliza esta tabla (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/) | ||
con el alfabeto y los números en "leet". | ||
(Usa la primera opción de cada transformación. Por ejemplo "4" para la "a") | ||
''' | ||
def translator(text): | ||
leet_speak = {'a': 4, 'b': 8, 'c': '<', 'd': '>', 'e': '&', 'f': 'v', 'g': 9, 'h': '#', | ||
'i': 1, 'j': ';', 'k': '1<', 'l': '£', 'm': '^^', 'n': 'И', 'o': 0, 'p': 9, | ||
'q': 2, 'r': 'Я', 's': 5, 't': 7, 'u': 'µ', 'v': '\/', 'w': 'Ш', 'x': 'ecks', | ||
'y': '¥', 'z': 's'} | ||
list_ls = [] | ||
|
||
for letter in text: | ||
if letter in leet_speak.keys(): | ||
list_ls.append(leet_speak[letter]) | ||
else: | ||
list_ls.append(letter) | ||
|
||
end_text = ''.join(map(str, list_ls)) | ||
return end_text | ||
|
||
|
||
test = 'Leet speak o leet es un tipo de escritura compuesta de caracteres alfanuméricos' | ||
print(translator(test)) | ||
|
||
user = input('Texto a traducir: ').lower() | ||
print(translator(user)) |
Oops, something went wrong.