No my friend, maybe you have the wrong idea, RegExp won'g help you count,
but only test, here is my code in Ruby :
It should be pretty easy to understand.
N.times do |i|
r = Regexp.new(input[i+D+1].gsub('(','[').gsub(')',']').to_s)
count = 0
words.each do |w|
count+=1 if !r.match(w).nil?
end
output.puts "Case ##{i}: #{count}\n"
end
Thanks & Regards,
Dhruva Sagar.
Ogden Nash <http://www.brainyquote.com/quotes/authors/o/ogden_nash.html> -
"The trouble with a kitten is that when it grows up, it's always a cat."
On Fri, Sep 4, 2009 at 8:40 PM, Satyajit Malugu
<[email protected]>wrote:
> You guys are all damn good at regex's I think. For the life of me, I simply
> thought regex's can't be done because I have to count the number of
> matches.
> Can you give the regex you've used?
>
> On Fri, Sep 4, 2009 at 5:21 AM, krzych <[email protected]> wrote:
>
>>
>> Hi,
>>
>> I solved first problem correctly in Perl for both small and large data
>> sets. I just used regular expression and I think that this was the
>> easiest (and requiring only a few lines of code) way to solve this
>> task. Since I'm not familiar with Perl I had some problems and my
>> regular expression is overcomplicated, but since it was working, I
>> left it like it was.
>>
>> Cheers,
>> Krzysztof.
>>
>> On Sep 4, 10:50 am, 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
>>
>>
>
>
> --
> Satyajit
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---