This commit is contained in:
2023-06-13 16:27:12 +02:00
parent 119e10c2a0
commit 0cb757c9e4
2 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
/*
* 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")
*/
fn main() {
let alphabet = String::from_utf8((b'A'..=b'Z').chain(b'0'..=b'9').collect()).unwrap();
println!("{}", alphabet);
let respuesta = [
"4",
"l3",
"[",
")",
"3",
"|=",
"&",
"#",
"1",
",_|",
">|",
"1",
"^^",
"^",
"0",
"|*",
"(_,)",
"l2",
"hu",
"gg",
"pesadooooooooo",
"0",
"yy",
"2",
"3",
"4",
];
let vecalphabet: Vec<_> = alphabet.split("").collect();
let texto = String::from("wtf hijo de puta hay que decirlo mas").to_uppercase();
let vectexto: Vec<_> = texto.split("").collect();
let mut textfinal = "".to_string();
for item in vectexto {
if alphabet.contains(item) {
let index = vecalphabet
.iter()
.position(|&r| r == item.to_string())
.unwrap();
if index != 0 {
//println!("es->{}", respuesta[index]);
textfinal += &respuesta[index].to_string();
}
}
}
println!("{}", textfinal)
}