Last active
October 24, 2015 22:09
-
-
Save tinkerstudent/71e06a67fd5490059aa1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package com.tinkeracademy.ap; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| 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', '\u0071', '\u0254', '\u0070','\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) { | |
| Map dict = Main.createDictionaries(); | |
| 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); | |
| char out = (char) dict.get(in); | |
| output = output + out; | |
| } | |
| System.out.println(output); | |
| } | |
| public static int findCharInArray(char in) { | |
| for (int i = 0; i < alphabets.length; i++) { | |
| if (alphabets[i] == in) { | |
| return i; | |
| } | |
| } | |
| System.out.println("cannot find char for " + in); | |
| return -1; | |
| } | |
| public static Map createDictionaries() { | |
| Map d = new HashMap(); | |
| for (int i = 0; i < alphabets.length; i++) { | |
| char key = alphabets[i]; | |
| char value = reverseAlphabets[i]; | |
| d.put(key, value); | |
| } | |
| return d; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment