Took around 1.5 hours to write this Algorithm.
When the submission to #gcj I have been tried total 3 times.
After 2 tries I figured out z =q and q=z :D
Totally I went 3 tries but last one is a loss, I thought it will automatically submitted after the count down though it didnt. :/

I got Full marks for this Algorithm.. hahahahha.. how cool it was..... :)

  Problem A. Speaking in Tongues

Problem

We have come up with the best possible language here at Google, called Googlerese. To translate text into Googlerese, we take any message and replace each English letter with another English letter. This mapping is one-to-one and onto, which means that the same input letter always gets replaced with the same output letter, and different input letters always get replaced with different output letters. A letter may be replaced by itself. Spaces are left as-is.
For example (and here is a hint!), our awesome translation algorithm includes the following three mappings: 'a' -> 'y', 'o' -> 'e', and 'z' -> 'q'. This means that "a zoo" will become "y qee".
Googlerese is based on the best possible replacement mapping, and we will never change it. It will always be the same. In every test case. We will not tell you the rest of our mapping because that would make the problem too easy, but there are a few examples below that may help.
Given some text in Googlerese, can you translate it to back to normal text?

Solving this problem

Usually, Google Code Jam problems have 1 Small input and 1 Large input. This problem has only 1 Small input. Once you have solved the Small input, you have finished solving this problem.

Input

The first line of the input gives the number of test cases, T. T test cases follow, one per line.
Each line consists of a string G in Googlerese, made up of one or more words containing the letters 'a' - 'z'. There will be exactly one space (' ') character between consecutive words and no spaces at the beginning or at the end of any line.

Output

For each test case, output one line containing "Case #X: S" where X is the case number and S is the string that becomes G in Googlerese.

Limits

1 ≤ T ≤ 30.
G contains at most 100 characters.
None of the text is guaranteed to be valid English.

Sample

Input
3
ejp mysljylc kd kxveddknmc re jsicpdrysi
rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd
de kr kd eoya kw aej tysr re ujdr lkgc jv


Output
Case #1: our language is impossible to understand
Case #2: there are twenty six factorial possibilities
Case #3: so it is okay if you want to just give up

My Answer!
_____________________________________________________

 

/**
 * Google Code Jam - Qualification Round 2012
 * Problem A. Speaking in Tongues
 * Author : harshadura@gmail.com
 * @harshadura
 */

import java.io.*;

public class Main {

    private static String[] EncryptedLines;
    private static String[] DecryptedLines;

    public static void main(String[] args) {

        int i = 0;
        int j = 0;
        int count = 0;

        try {
            FileInputStream fstream = new FileInputStream("C:\\Users\\Harsha\\Documents\\NetBeansProjects\\GoogleCodeJamA\\A-small-attempt3.in");
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;

            EncryptedLines = new String[100];

            while ((strLine = br.readLine()) != null) {
                EncryptedLines[i++] = strLine;
                System.out.println(strLine);
                ++count;
            }
            in.close();
        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
        }

        DecryptedLines = new String[count - 1];
        int numTests = Integer.valueOf(EncryptedLines[0]);

        if (numTests < 1 || numTests > 30){
            System.out.println("Invalid Input!!!!!!!!");
            System.exit(0);
        }

        for (i = 1; i <= numTests; i++) {
            DecryptedLines[j++] = "Case #" + i + ": " + ConvertLine(EncryptedLines[i]);
        }

        String writableString = "";

        for (int k = 0; k < DecryptedLines.length; k++) {
            if (k + 1 == DecryptedLines.length) {
                writableString = writableString + DecryptedLines[k];
                break;
            }
            writableString = writableString + DecryptedLines[k] + "\n";
        }

        writeToFile(writableString);
    }

    public static String ConvertLine(String plainText) {
        int size = plainText.length();
        String decripted = "";
        
        if (size > 100) { 
            System.out.println("More than 100 Characters exceeded for a Single Case and Thats Invalid!!!!!!!!");
            System.exit(0);
        }

        for (int i = 0; i < size; i++) {
            decripted = decripted + charMap(plainText.charAt(i));
        }
        return decripted;
    }

    public static void writeToFile(String WrittenText) {
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String file_name = "A-small-attempt3.out";
            FileWriter fstream = new FileWriter(file_name);
            BufferedWriter out = new BufferedWriter(fstream);
            out.write(WrittenText);
            out.close();
            System.out.println("File created successfully.");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    public static char charMap(char x) {
        switch (x) {
            case 'a':
                return 'y';
            case 'b':
                return 'h';
            case 'c':
                return 'e';
            case 'd':
                return 's';
            case 'e':
                return 'o';
            case 'f':
                return 'c';
            case 'g':
                return 'v';
            case 'h':
                return 'x';
            case 'i':
                return 'd';
            case 'j':
                return 'u';
            case 'k':
                return 'i';
            case 'l':
                return 'g';
            case 'm':
                return 'l';
            case 'n':
                return 'b';
            case 'o':
                return 'k';
            case 'p':
                return 'r';
            case 'q':
                return 'z';
            case 'r':
                return 't';
            case 's':
                return 'n';
            case 't':
                return 'w';
            case 'u':
                return 'j';
            case 'v':
                return 'p';
            case 'w':
                return 'f';
            case 'x':
                return 'm';
            case 'y':
                return 'a';
            case 'z':
                return 'q';
        }
        return x;
    }
}