Skip to content

Instantly share code, notes, and snippets.

@tinkerstudent
Last active October 24, 2015 20:53
Show Gist options
  • Save tinkerstudent/040b260927d10338b150 to your computer and use it in GitHub Desktop.
Save tinkerstudent/040b260927d10338b150 to your computer and use it in GitHub Desktop.
package com.tinkeracademy.ap;
import java.util.Scanner;
public class Main {
public static char[] alphabets = new char[] { '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', ' ', '!', 'W', 'P',
'H', '1', '7', '2'
};
public static char[] reverseAlphabets = new char[] {
'\u0250', '\u0062', '\u0254', '\u0064','\u01DD',
'\u025F', '\u0183', '\u0265', '\u1D09','\u027E',
'\u029E', '\u0031','\u026F','\u0075','\u006F',
'\u0064','\u0062','\u0279','\u0073','\u0287',
'\u006E','\u028C','\u028D','\u0078','\u028E',
'\u007A',' ', '\u00A1', '\u004D', '\u0500',
'\u0048', '\u0196','\u3125', '\u1105' };
public static void main(String[] args) {
String output = "";
Scanner s = new Scanner(System.in);
String input = s.nextLine();
for (int i = input.length() - 1; i >= 0; i--) {
char in = input.charAt(i);
int index = Main.findCharInArray(in);
char out = alphabets[index];
output = output + out;
}
System.out.println(output);
System.out.println(output.hashCode());
}
public static int findCharInArray(char in) {
for (int i = 0; i < reverseAlphabets.length; i++) {
if (reverseAlphabets[i] == in) {
return i;
}
}
System.out.println("cannot find char for " + in);
return -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment