Caine Tuts - More GREP and REGEXP

Problem completing one of the interactive tutorials?

Moderator: drgrussell

Post Reply
rotten

Caine Tuts - More GREP and REGEXP

Post by rotten » Sun Oct 12, 2014 11:21 pm

Greetings Mr. G! How're you doing?

I'm still having hard time figuring out what am i missing on question 3:
The word interlinking includes the same two characters (e.g. "in") which appear three times. The word "priestessess" also contains the same two characters repeated three time (e.g. "es").
How many words can you find which contain any two characters repeated three times, like the examples "interlinking" and "priestessess". Use /usr/share/dict/words as your list of possible words and grep to find the answer.
56 is the highest number of occurrences i've found so far:

Code: Select all

$ grep -i '\(\w\)\(\w\).*\1\2.*\1\2' $DIC
Antananarivo
Antananarivo's
Christchurch
Ouagadougou
Panamanian
Panamanian's
Panamanians
Tanzanian
Tanzanian's
Tanzanians
analyticalally
ancestresses
confrontation
confrontation's
confrontational
confrontations
contentment
contentment's
discontentment
discontentment's
disinclining
enlightenment
enlightenment's
entrenchment
entrenchment's
entrenchments
fingerprinting
incinerating
inclining
incriminating
indoctrinating
infringing
ingraining
inseminating
insinuating
intercontinental
interlinking
intermingling
intertwining
mainlining
maintaining
pinpointing
possessiveness
possessiveness's
preregistered
priestesses
rededicated
restlessness
restlessness's
singsonging
tintinnabulation
tintinnabulation's
tintinnabulations
titillating
titillation
titillation's
Could you kindly help me on this one? Thanks in advance!
Best Regards,
rOttEn

drgrussell
Site Admin
Posts: 426
Joined: Sat Feb 12, 2005 8:57 pm
Are you a robot or a human?: Human

Re: Caine Tuts - More GREP and REGEXP

Post by drgrussell » Mon Oct 13, 2014 5:43 pm

The tutorials are designed only for a restricted set of regexp parameters.
Althought \w seems natural, my students have not been taught it, and it stops some matches.
I envisaged "." rather than "\w".
(..) and then just \1 seems nicer.

rotten

Re: Caine Tuts - More GREP and REGEXP

Post by rotten » Fri Oct 17, 2014 6:53 pm

Dear Mr. G,

I've changed my code to the following

Code: Select all

 grep -i '\(..\).*\1.*\1.*' $DICTIONARY_FILE
But it still gives me the same answer: 56 total. Which is dead wrong.

What am i still missing, professor?

Looking forward for your answer,
rOttEn

drgrussell
Site Admin
Posts: 426
Joined: Sat Feb 12, 2005 8:57 pm
Are you a robot or a human?: Human

Re: Caine Tuts - More GREP and REGEXP

Post by drgrussell » Fri Oct 17, 2014 7:05 pm

I wonder...
I didn't use -i myself...

rotten

Re: Caine Tuts - More GREP and REGEXP

Post by rotten » Fri Oct 17, 2014 7:18 pm

:lol: I've passed it =)))))))))

rotten

Re: Caine Tuts - More GREP and REGEXP

Post by rotten » Fri Oct 17, 2014 7:25 pm

Thank you very much for your quick return, Mr. G!

Last thought: shouldn't using "-i" be desirable? It matches X more words than not using it, and also meet the requirements of what is asked on the question.. How do you feel about it? (changing the answer ;)

Have a great weekend! And thank you for putting up with me :D
Best regards,
rOttEn

drgrussell
Site Admin
Posts: 426
Joined: Sat Feb 12, 2005 8:57 pm
Are you a robot or a human?: Human

Re: Caine Tuts - More GREP and REGEXP

Post by drgrussell » Sat Oct 18, 2014 7:13 pm

Well strictly speaking it says "the same characters", and characters "a" and "A" are actually different characters, so case sensitivity seems something you need.
But in reality I am always aiming for the simplest answer.
I will add something into the words of the question.
Kind Regards
Gordon.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests