Working of large dataset also..i corrected my mistake.

On Thu, Jul 28, 2011 at 9:52 AM, Satyajit Bhadange <
[email protected]> wrote:

> The solution worked for small input,but doestn work for large input
> file.Any suggestions.
>
> And About scanner class,thanks..will definitely try to use it in next
> practice example.
>
>   On Wed, Jul 27, 2011 at 6:34 PM, Niranjan <[email protected]>wrote:
>
>> the output expected is  " is ruled by nobody." and not " is ruled by a
>> nobody."
>>
>> Try java.util.Scanner for reading from files, its much cleaner &
>> easier
>>
>>
>> On Jul 27, 5:22 am, Satyajit Bhadange <[email protected]>
>> wrote:
>> > *
>> > Can ay one tell me whats wrong with my code ? why i am getting wrong
>> anwer.
>> >
>> > Problem Statemet is
>> > here<http://code.google.com/codejam/contest/dashboard?c=1277486#s=p0>
>>  >
>> > import
>> > * java.io.BufferedReader;*
>> >
>> > import
>> > * java.io.BufferedWriter;*
>> >
>> > import
>> > * java.io.FileReader;*
>> >
>> > import
>> > * java.io.FileWriter;
>> >
>> >  *
>> >
>> > public
>> > * *class* CentauriPrime {
>> >
>> > /**
>> >
>> > * *@param* args
>> >
>> > */
>> >
>> > *public* *static* *void* main(String[] args) *throws* Exception{
>> >
>> > BufferedReader bfrd =
>> > *new* BufferedReader(*new* FileReader("A-small-practice.in"));
>> >
>> > BufferedWriter bfrw =
>> > *new* BufferedWriter(*new* FileWriter("output.out"));
>> >
>> > *int* n = Integer.*parseInt*(bfrd.readLine());
>> >
>> > String output =
>> > "";
>> >
>> >  *for*(*int* i = 0; i < n; i++) {
>> >
>> > String s = bfrd.readLine();
>> >
>> > output +=
>> > "Case #" + (i + 1) + ": ";
>> >
>> > output += *ruledBy*(s);
>> >
>> > output += i == n - 1 ?
>> > "" : "\n";
>> >
>> > }
>> >
>> > bfrw.write(output);
>> >
>> > bfrw.close();
>> >
>> > bfrd.close();
>> >
>> > }
>> >
>> > *private* *static* String ruledBy(String s) {
>> >
>> > *if*(s.charAt(s.length()-1) == 'a' || s.charAt(s.length()-1) == 'e' ||
>> >
>> > s.charAt(s.length()-1) ==
>> > 'i' || s.charAt(s.length()-1) == 'o' ||
>> >
>> > s.charAt(s.length()-1) ==
>> > 'u') {
>> >
>> > *return* s + " is ruled by a queen.";
>> >
>> > }
>> >
>> > *else* *if* (s.charAt(s.length()-1) == 'y') {
>> >
>> > *return* s + " is ruled by a nobody.";
>> >
>> > }
>> >
>> > *else* {
>> >
>> > *return* s + " is ruled by a king.";
>> >
>> > }
>> > }
>> > }
>> >
>> > Thanks & Regards,
>> > Satyajit Bhadange
>> >
>> > Problems & Solutions <http://satyajit-algorithms.blogspot.com/>
>>
>> --
>>  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.
>>
>>
>
>
> --
>
> Thanks & Regards,
> Satyajit Bhadange
>
> Problems & Solutions <http://satyajit-algorithms.blogspot.com/>
>
>


-- 

Thanks & Regards,
Satyajit Bhadange

Problems & Solutions <http://satyajit-algorithms.blogspot.com/>

-- 
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