Skip to content

Commit

Permalink
Reto mouredev#1 - Leet (1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandresca committed Jul 30, 2023
1 parent 3da8bfc commit 782ee90
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/java/vandresca.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.util.Scanner;


/**
Transformar un texto o una frase al lenguaje hacker "leet"(1337)
*/
class vandresca {

private static String[] normalAlphabet = {"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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", " "};

private static String[] leetAlphabet = {"4", "|3", "[", "|)", "3", "|=", "6", "/-/","|", "_/",
"|<", "1", "|v|", "|\\|", "0", "/>", "0,", "|2", "5", "7", "|_|", "\\/", "\\/\\/", "><","j", "2",
"O", "L" ,"R", "E", "A", "S", "b", "T", "B", "g", " "};

private static final String EMPTY_STRING = "";


public static void main(String[] args) {
print("Introduce un texto;");
String inputText = requestText();
print("La cadena resultante es: "+ translateText(inputText));
}

private static String requestText(){
Scanner input = new Scanner(System.in);
String inputText = input.nextLine().toUpperCase();
input.close();
return inputText;
}

private static String translateText(String inputText){
String outputText = "";
for(int i=0; i<inputText.length(); i++){
outputText += translateCharacter(inputText.charAt(i));
}
return outputText;
}

private static String translateCharacter(Character character){
for(int i=0; i<normalAlphabet.length; i++){
if(normalAlphabet[i].equals(character.toString())){
return leetAlphabet[i];
}
}
return EMPTY_STRING;
}

private static void print(String text){
System.out.println(text);
}
}

0 comments on commit 782ee90

Please sign in to comment.