Skip to content

Commit 0359dbd

Browse files
committed
2 parents 52596ff + f4f7a7f commit 0359dbd

File tree

2 files changed

+80
-56
lines changed
  • Retos
    • Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/python
    • Reto #1 - EL LENGUAJE HACKER [Fácil]/python

2 files changed

+80
-56
lines changed
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
num = 1
1+
"""/*
2+
* Escribe un programa que muestre por consola (con un print) los
3+
* números de 1 a 100 (ambos incluidos y con un salto de línea entre
4+
* cada impresión), sustituyendo los siguientes:
5+
* - Múltiplos de 3 por la palabra "fizz".
6+
* - Múltiplos de 5 por la palabra "buzz".
7+
* - Múltiplos de 3 y de 5 a la vez por la palabra "fizzbuzz".
8+
*/"""
29

3-
while num <= 100:
4-
if num % 3 == 0 and num % 5 == 0:
5-
print('fizz buzz\n')
6-
elif num % 3 == 0:
7-
print('fizz\n')
8-
elif num % 5 == 0:
9-
print('buzz\n')
10-
else:
11-
print(f'{num}\n')
12-
13-
num+=1
10+
def fizz_buzz():
11+
for i in range(1, 100):
12+
if i%3 ==0 and i%5 == 0:
13+
print("Fizz Buzz")
14+
elif i%3 == 0:
15+
print("Fizz")
16+
elif i%5 == 0:
17+
print("Buzz")
18+
else: print(i)
19+
20+
fizz_buzz()
Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,66 @@
1-
#Definimos el diccionario para relacionar cada letra del alfabeto español al leet
2-
dictionary = {
3-
"A" : "4",
4-
"B" : "I3",
5-
"C" : "[",
6-
"D" : ")",
7-
"E" : "3",
8-
"F" : "|=",
9-
"G" : "&",
10-
"H" : "#",
11-
"I" : "1",
12-
"J" : ",_|",
13-
"K" : ">|",
14-
"L" : "1",
15-
"M" : "/\\/\\",
16-
"N" : "^/",
17-
"O" : "0",
18-
"P" : "|*",
19-
"Q" : "(_,)",
20-
"R" : "I2",
21-
"S" : "5",
22-
"T" : "7",
23-
"U" : "(_)",
24-
"V" : "\\/",
25-
"W" : "\\/\\/",
26-
"X" : "><",
27-
"Y" : "j",
28-
"Z" : "2"
1+
"""
2+
/*
3+
* Escribe un programa que reciba un texto y transforme lenguaje natural a
4+
* "lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje
5+
* se caracteriza por sustituir caracteres alfanuméricos.
6+
* - Utiliza esta tabla (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/)
7+
* con el alfabeto y los números en "leet".
8+
* (Usa la primera opción de cada transformación. Por ejemplo "4" para la "a")
9+
*/
10+
"""
11+
12+
leet_letters = {
13+
"a" : "4",
14+
"b" : "I3",
15+
"c" : "[",
16+
"d" : ")",
17+
"e" : "3",
18+
"f" : "|:",
19+
"g" : "6",
20+
"h" : "#",
21+
"i" : "1",
22+
"j" : ",_|",
23+
"k" : ">|",
24+
"l" : "1",
25+
"m" : "[V]",
26+
"n" : "^/",
27+
"o" : "0",
28+
"p" : "|*",
29+
"q" : "(_,)",
30+
"r" : "I2",
31+
"s" : "5",
32+
"t" : "7",
33+
"u" : "(_)",
34+
"v" : "|/",
35+
"w" : "(n)",
36+
"x" : "><",
37+
"y" : "j",
38+
"z" : "2",
39+
"1" : "L",
40+
"2" : "R",
41+
"3" : "E",
42+
"4" : "A",
43+
"5" : "S",
44+
"6" : "b",
45+
"7" : "T",
46+
"8" : "B",
47+
"9" : "g",
48+
"0" : "o",
49+
" " : " "
2950
}
3051

31-
def translate(text:str):
32-
33-
#Eliminamos espacios al inicio y final y pasamos todas las letras a mayúsculas
34-
text_upper = text.strip()
35-
text_upper = text.upper()
52+
def hacker_languaje(word):
3653

37-
translated_text = ""
54+
leet_word = []
55+
i = 0
3856

39-
for character in text_upper:
40-
#Verificamos que el caracter esta en el diccionario
41-
if character in dictionary.keys():
42-
translated_text += dictionary[character]
43-
#Si no está se le agrega al texto traducido directamente por no tener traducción en el leguaje leet
44-
else:
45-
translated_text += character
46-
return translated_text
57+
for letter in word:
4758

48-
#Ejemplo de uso de la función
49-
print(translate("Hello Python !"))
59+
if i < len(word):
60+
leet_word.append(leet_letters[letter])
61+
i+=1
62+
63+
return "".join(leet_word)
64+
65+
word_to_traduce = input("Indique la palabra a traducir: \n")
66+
print(hacker_languaje(word_to_traduce))

0 commit comments

Comments
 (0)