-
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 'mouredev:main' into main
- Loading branch information
Showing
9 changed files
with
412 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
Retos/Reto #28 - EXPRESIÓN MATEMÁTICA [Media]/python/majinka10.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,15 @@ | ||
import re | ||
|
||
patron = re.compile(r'-?\d+(\.\d+)?\s*[+\-*/%]\s*-?\d+(\.\d+)?(?:\s*[+\-*/%]\s*-?\d+(\.\d+)?)?') | ||
|
||
def evaluador(expresion:str): | ||
match = patron.search(expresion) | ||
if match: | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
print(evaluador('5 + 6 / 7 - 4')) | ||
print(evaluador('5 a 3')) | ||
print(evaluador('3.2 % 3 + 5 - 3 / 2')) |
47 changes: 47 additions & 0 deletions
47
Retos/Reto #29 - EL CARÁCTER INFILTRADO [Fácil]/java/jesusWay69.java
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,47 @@ | ||
package reto_29; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Crea una función que reciba dos cadenas de texto casi iguales, a excepción de | ||
* uno o varios caracteres. La función debe encontrarlos y retornarlos en | ||
* formato lista/array. - Ambas cadenas de texto deben ser iguales en longitud. | ||
* - Las cadenas de texto son iguales elemento a elemento. - No se pueden | ||
* utilizar operaciones propias del lenguaje que lo resuelvan directamente. | ||
* | ||
* Ejemplos: - Me llamo mouredev / Me llemo mouredov -> ["e", "o"] - Me | ||
* llamo.Brais Moure / Me llamo brais moure -> [" ", "b", "m"] | ||
* | ||
* @author jesus | ||
*/ | ||
public class jesusWay69 { | ||
|
||
public static void main(String[] args) { | ||
String text1 = "hola mundo"; | ||
String text2 = "Hola mubdO"; | ||
comparator(text1, text2); | ||
|
||
} | ||
|
||
private static void comparator(String text1, String text2) { | ||
|
||
var differentCharacters = new ArrayList<String>(); | ||
|
||
if (text1.length() == text2.length()) { | ||
|
||
for (int i = 0; i < text1.length(); i++) | ||
|
||
if ((text1.charAt(i) != text2.charAt(i))) | ||
|
||
differentCharacters.add(Character.toString(text2.charAt(i))); | ||
|
||
} | ||
|
||
if (differentCharacters.isEmpty()) System.out.println("Los 2 textos son idénticos o tienen diferente longitud"); | ||
|
||
else System.out.println(differentCharacters); | ||
|
||
|
||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
Retos/Reto #29 - EL CARÁCTER INFILTRADO [Fácil]/python/ShinMugenNoKabe.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,33 @@ | ||
# Crea una función que reciba dos cadenas de texto casi iguales, | ||
# a excepción de uno o varios caracteres. | ||
# La función debe encontrarlos y retornarlos en formato lista/array. | ||
# - Ambas cadenas de texto deben ser iguales en longitud. | ||
# - Las cadenas de texto son iguales elemento a elemento. | ||
# - No se pueden utilizar operaciones propias del lenguaje | ||
# que lo resuelvan directamente. | ||
# | ||
# Ejemplos: | ||
# - Me llamo mouredev / Me llemo mouredov -> ["e", "o"] | ||
# - Me llamo.Brais Moure / Me llamo brais moure -> [" ", "b", "m"] | ||
|
||
def find_differences(text1: str, text2: str) -> list[str]: | ||
if text1 is None or text2 is None: | ||
raise ValueError("Introduce un texto válido") | ||
elif len(text1) != len(text2): | ||
raise ValueError("Las cadenas de texto deben tener el mismo número de carácteres") | ||
|
||
return [char2 for char1, char2 in zip(text1, text2) if char1 != char2] | ||
|
||
|
||
if __name__ == "__main__": | ||
diff1 = find_differences("Me llamo mouredev", "Me llemo mouredov") | ||
assert diff1 == ["e", "o"] | ||
print(diff1) | ||
|
||
diff2 = find_differences("Me llamo.Brais Moure", "Me llamo brais moure") | ||
assert diff2 == [" ", "b", "m"] | ||
print(diff2) | ||
|
||
text1 = input("Introduce la primera cadena de carácteres: ") | ||
text2 = input("Introduce la segunda cadena de carácteres: ") | ||
print(find_differences(text1, text2)) |
13 changes: 13 additions & 0 deletions
13
Retos/Reto #29 - EL CARÁCTER INFILTRADO [Fácil]/python/majinka10.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,13 @@ | ||
def infiltrado(texto1:str,texto2:str): | ||
infiltrados=[] | ||
if len(texto1) == len(texto2): | ||
for tupla in zip(texto1,texto2): | ||
if tupla[0] != tupla[1]: | ||
infiltrados.append(tupla[0]) | ||
else: | ||
return print('Los textos no tienen el mismo tamaño') | ||
return print(infiltrados) | ||
|
||
infiltrado('abc','abdc') | ||
infiltrado('Me llamo mouredev','Me llemo mouredov') | ||
infiltrado('Me llamo.Brais Moure','Me llamo brais moure') |
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,75 @@ | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
/* | ||
* 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 | ||
*/ | ||
|
||
|
||
namespace reto; | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine(T9KeyboardToText("6-666-88-777-33-3-33-888")); //MOUREDEV | ||
Console.WriteLine(T9KeyboardToText("22-777-2-444-7777-0-33-7777-0-6-666-88-777-33-3-33-888-11")); //BRAIS ES MOUREDEV. | ||
Console.WriteLine(T9KeyboardToText("666666-666-88-777-33-3-33-888")); //Error. Wrong text input. Wrong length. | ||
Console.WriteLine(T9KeyboardToText("6-686-88-777-33-3-33-888")); //Error. Wrong text input. No number or if a block has more than one number, it must always be the same. | ||
Console.WriteLine(T9KeyboardToText("6-686-88-777-33-3-33-")); //Error. Wrong text input. No number or if a block has more than one number, it must always be the same. | ||
Console.WriteLine(T9KeyboardToText("6,686-88-777-33-3-33-888")); //Error. Wrong text input. Wrong text format. | ||
|
||
} | ||
|
||
static string T9KeyboardToText(string numbers) | ||
{ | ||
if(!Regex.IsMatch(numbers,@"^(\d+(\-)?)*$")) return "Error. Wrong text input. Wrong text format."; | ||
|
||
string[][] t9 = new string[][] | ||
{ | ||
new string[] {" "}, | ||
new string[] {",", ".","!","?"}, | ||
new string[] {"a", "b","c"}, | ||
new string[] {"d", "e","f"}, | ||
new string[] {"g", "h","i"}, | ||
new string[] {"j", "k","l"}, | ||
new string[] {"m", "n","o","ñ"}, | ||
new string[] {"p", "q","r","s"}, | ||
new string[] {"t", "u","v"}, | ||
new string[] {"w", "x","y","z"}, | ||
}; | ||
|
||
StringBuilder message= new StringBuilder(); | ||
|
||
string[] splitString = numbers.Split('-'); | ||
|
||
foreach (string item in splitString) | ||
{ | ||
if(!Regex.IsMatch(item, @"^(\d)\1*$")) return "Error. Wrong text input. No number or if a block has more than one number, it must always be the same."; | ||
|
||
try | ||
{ | ||
message.Append(t9[(int)Char.GetNumericValue(item[0])][item.Length - 1]); | ||
} | ||
catch (System.Exception) | ||
{ | ||
|
||
return "Error. Wrong text input. Wrong length."; | ||
} | ||
|
||
} | ||
|
||
return message.ToString().ToUpper(); | ||
} | ||
|
||
|
||
} |
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,88 @@ | ||
namespace Reto_30 | ||
{ | ||
internal class Program | ||
{ | ||
static Dictionary<string, string> t9 = new Dictionary<string, string>() | ||
{ | ||
{"1", "@"}, | ||
{"2", "a"}, | ||
{"22", "b"}, | ||
{"222", "c"}, | ||
{"3", "d"}, | ||
{"33", "e"}, | ||
{"333", "f"}, | ||
{"4", "g"}, | ||
{"44", "h"}, | ||
{"444", "i"}, | ||
{"5", "j"}, | ||
{"55", "k"}, | ||
{"555", "l"}, | ||
{"6", "m"}, | ||
{"66", "n"}, | ||
{"666", "o"}, | ||
{"7", "p"}, | ||
{"77", "q"}, | ||
{"777", "r"}, | ||
{"7777", "s"}, | ||
{"8", "t"}, | ||
{"88", "u"}, | ||
{"888", "v"}, | ||
{"9", "w"}, | ||
{"99", "x"}, | ||
{"999", "y"}, | ||
{"9999", "z"}, | ||
{"0", " "}, | ||
{"-", ""} | ||
}; | ||
|
||
static void Main(string[] args) | ||
{ | ||
string start = ""; | ||
Console.WriteLine("Pulse ENTER para empezar, o cualquier otra letra para cerrar."); | ||
|
||
while (start == "") | ||
{ | ||
Console.WriteLine("Bienvenido al teclado T9."); | ||
Console.WriteLine("Pulsa ENTER para continuar..."); | ||
string enter = Console.ReadLine(); | ||
|
||
while (enter != "") | ||
{ | ||
Console.WriteLine("¡Uepa! Debes de pulsar ENTER."); | ||
enter = Console.ReadLine(); | ||
} | ||
|
||
keyboardT9(); | ||
Console.WriteLine("Pulse ENTER para escribir otro mensaje o cualquier otra letra para cerrar."); | ||
start = Console.ReadLine(); | ||
} | ||
} | ||
|
||
static void keyboardT9() | ||
{ | ||
Console.WriteLine("Escriba texto usando el teclado númerico (0-9). Si escribes solo un carácter, debes de finalizar con guón."); | ||
Console.WriteLine("Ejemplos: \n4- = g \n44-666-555-2 = hola"); | ||
Console.WriteLine("Esciba los números a traducir a continuación:"); | ||
string input = Console.ReadLine(); | ||
|
||
while (t9.TryGetValue(input, out string numberKey)) //Si escribimos algo que no es un número o una "-" sola, da error y volvemos a pedir la entrada. | ||
{ | ||
Console.WriteLine("¡Uepa! Debes de escibir un número como en el sistema T9."); | ||
input = Console.ReadLine(); | ||
} | ||
|
||
string[] message = input.Split("-"); //Transformamos el input en un arreglo de cadenas. Con el método Split(); las separamos mediante "-". | ||
|
||
string output = ""; | ||
|
||
for (int i=0; i<message.Length; i++) // Recorremos cada letra del input y buscamos su correspondiente traducción. | ||
{ | ||
if (t9.ContainsKey(message[i].ToString())) | ||
{ | ||
output = output + t9[message[i].ToString()]; | ||
} | ||
} | ||
Console.WriteLine(output); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
Retos/Reto #30 - EL TECLADO T9 [Media]/java/jesusWay69.java
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,70 @@ | ||
package reto_30; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* * 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 | ||
* | ||
* @author jesus | ||
*/ | ||
public class jesusWay69 { | ||
|
||
public static void main(String[] args) { | ||
|
||
String keys = "44-33-555-555-666-0-9-666-777-555-3"; | ||
alphabet_hm(keys); | ||
|
||
} | ||
|
||
private static void alphabet_hm(String keys) { | ||
String text = ""; | ||
|
||
Map<String, String> letters_hm = new HashMap<String, String>(); | ||
letters_hm.put("2", "A"); | ||
letters_hm.put("22", "B"); | ||
letters_hm.put("222", "C"); | ||
letters_hm.put("3", "D"); | ||
letters_hm.put("33", "E"); | ||
letters_hm.put("333", "F"); | ||
letters_hm.put("4", "G"); | ||
letters_hm.put("44", "H"); | ||
letters_hm.put("444", "I"); | ||
letters_hm.put("5", "J"); | ||
letters_hm.put("55", "K"); | ||
letters_hm.put("555", "L"); | ||
letters_hm.put("6", "M"); | ||
letters_hm.put("66", "N"); | ||
letters_hm.put("6666", "Ñ"); | ||
letters_hm.put("666", "O"); | ||
letters_hm.put("7", "P"); | ||
letters_hm.put("77", "Q"); | ||
letters_hm.put("777", "R"); | ||
letters_hm.put("7777", "S"); | ||
letters_hm.put("8", "T"); | ||
letters_hm.put("88", "U"); | ||
letters_hm.put("888", "V"); | ||
letters_hm.put("9", "W"); | ||
letters_hm.put("99", "X"); | ||
letters_hm.put("999", "Y"); | ||
letters_hm.put("9999", "Z"); | ||
letters_hm.put("0", " "); | ||
for (String key : keys.split("-")) { | ||
if (letters_hm.containsKey(key)) { | ||
|
||
|
||
text = text + letters_hm.get(key); | ||
} | ||
} | ||
|
||
System.out.println(text); | ||
} | ||
} |
Oops, something went wrong.