This is my Solution in Java!!

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class alien {

    /**
     * @param args
     * @throws FileNotFoundException
     */
    public static void main(String[] args) throws FileNotFoundException {

        Scanner in = new Scanner(new File("aliens.in"));
        PrintWriter out = new PrintWriter(new File("aliens.out"));

        String[] data = in.nextLine().split(" ");

        int l = Integer.parseInt(data[0]);
        int d = Integer.parseInt(data[1]);
        int cas = Integer.parseInt(data[2]);

        String rawWord;
        int count = 0;


        String[] dico = new String[d];

        for (int i = 0; i < dico.length; i++) {
            dico[i] = in.nextLine();
        }

        for (int i = 1; i <= cas; i++) {

            rawWord = in.nextLine();

            List<String> cases = new ArrayList<String>();
            String mot = "";
            char currentDictionnaryChar;
            String letters = "";

            cases = getTokens(rawWord);




             // on traite chaque mot du dico pour vérifier si oui ou non il
peut
             // être construit avec la chaine reçue
             for (int j = 0; j < dico.length; j++) {

                mot = dico[j];

                boolean found = true;

                    for (int k = 0; k < l; k++) {


                        currentDictionnaryChar = mot.charAt(k);

                        letters = cases.get(k);
                        if(letters.indexOf(""+currentDictionnaryChar) ==
-1){
                            found = false;
                            break;
                        }

                    }
                    if(found) count++;
            } // tous les mots du dico sont traités

             out.print("Case #"+ i +": "+count);
             count = 0;
             if(in.hasNext()) out.println();
        }
        out.close();


    }

   public static List<String> getTokens(String raw) {

       List<String> temp = new ArrayList<String>();
       StringBuffer rawTemp = new StringBuffer(raw);

       int i = 0, j = 0;
       while(rawTemp.capacity() != 0){
            i = rawTemp.indexOf("(") ;
            j = rawTemp.indexOf(")") ;
            switch(i) {
            case 0:

                   temp.add("" + rawTemp.substring(i+1, j));
                   rawTemp =  rawTemp.delete(i, j+1);
                   break;
            case -1 :

                    for (int j2 = 0; j2 < rawTemp.length(); j2++) {
                        temp.add("" + rawTemp.charAt(j2));
                    }

                      rawTemp =  rawTemp.delete(0, rawTemp.length());
                      break;
              default :

                      for (int j2 = 0; j2 < i; j2++) {
                          temp.add("" + rawTemp.charAt(j2));
                    }
                       rawTemp = rawTemp.delete(0, i);
                        break;
               }



           rawTemp.trimToSize();

        }
       return temp;
   }





}






2011/5/6 이홍일 <[email protected]>

> You can get source code on scoreboard.
> That is not difficult problem.
> You can get solution if you think little more.
>
> 2011/5/6 Matty <[email protected]>
>
>> Does anybody have a solution code for this problem written in Java?
>> I'm stuck...
>>
>> Thanks in advance,
>>
>> Matt
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-codejam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-code?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to