Hey Ketan!
I solved it using perl and is very much fast and got me qualified.
YEAH:
open(INFILE, '<A-large.in');
open(OUTFILE, '>A-large.out');
$FirstLine = <INFILE>;
@LineF = split(/\s/, $FirstLine);
$Noofwords = @LineF[1];
$TestCases = @LineF[2];
@Words = ();
for($i = 0; $i<$Noofwords;$i++)
{
$str = <INFILE>;
push(@Words, $str);
}
for($CurTestCase = 1; $CurTestCase <= $TestCases; $CurTestCase++)
{
$CurrentLine = <INFILE>;
$CurrentLine =~ s/\(/\[/g;
$CurrentLine =~ s/\)/\]/g;
$CurrentLine =~ s/^\s+|\s+$//g ;
$noofoc = 0;
foreach $word (@Words)
{
while($word =~ /$CurrentLine/g)
{
$noofoc++;
}
}
$strtoprint = "Case #" . $CurTestCase . ": " . $noofoc . "\n";
print $strtoprint;
print OUTFILE $strtoprint;
}
On Sep 4, 1:50 pm, KeJo <[email protected]> wrote:
> Hi,
>
> anyone solved all problems correctly using perl?
>
> I did it, but I feel there could be better ways to do it in perl.
> Please let me know so that I can compare.
>
> Regards,
> KeJo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---