Skip to content

Instantly share code, notes, and snippets.

@chintanparikh
Created September 10, 2012 05:56
Show Gist options
  • Save chintanparikh/3689129 to your computer and use it in GitHub Desktop.
Save chintanparikh/3689129 to your computer and use it in GitHub Desktop.
import java.util.*;
/**
* LeetTranslator translates text into leetspeak
*/
public class LeetTranslator {
public static void main(String[] args) {
// Create the mapping between normal characters and leet speak
Map<Character, Character> leetMap = new HashMap<Character, Character>();
leetMap.put('a', '@');
leetMap.put('e', '3');
leetMap.put('i', '1');
leetMap.put('s', '5');
leetMap.put('o', '0');
Scanner scan = new Scanner(System.in);
System.out.print("Enter text to translate: ");
String normalInput = scan.nextLine();
String output = normalInput;
Iterator leetIterator = leetMap.keySet().iterator();
while(leetIterator.hasNext()) {
Character key = (Character)leetInterator.next();
output = output.replace(key, leetMap.get(key));
}
System.out.println(output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment