Caine Tuts - Question 3 - GREP and REGEX

Problem completing one of the interactive tutorials?

Moderator: drgrussell

Post Reply
rotten

Caine Tuts - Question 3 - GREP and REGEX

Post by rotten » Mon Oct 06, 2014 8:10 pm

Hello, Mr. Gordon! How're you doing?

I've been stuck on these 2 problems for two weeks now.. (T__T) Sometimes i feel i'm getting close, but i just can't solve these! :x

#1 - Trying to match all words which contains all vowels (AEIOU) in order:

Code: Select all

 grep -Ei '*a[^eiou]*e[^aiou]*i[^aeou]*o[^aeiu]*u[^aeio]*[^aeiou]$' $DIC 
Gives me the following output:
  • abstemious
    adventitious
    facetious
    facetiously

This variation [ grep -Ei '*a[^eiou]*e[^aiou]*i[^aeou]*o[^aeiu]*u[^aeio]*' ] of the above code gives me the same output, but including two more words:
  • facetiousness
    facetiousness's

I don't want the answer :!: i just wanna know: what am i missing :?: Which one is closer: the 1st or the 2nd approach?

#2 - How many words can you find which contain any two characters repeated three times, like the examples "interlinking" and "priestessess".

About the problem #2, i've already asked about it in Linux forums. I just want to point a minor mistake on check button of this question.. it reads:
  • Three character string appears 3 times (takes a few seconds)

It's a bit confusing :cry: Do we have to check for two or three character string appearing 3 times?

I appreciate your attention and patience and i'm looking forward for your answer!

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 - Question 3 - GREP and REGEX

Post by drgrussell » Tue Oct 07, 2014 7:03 pm

[aeiou] would find vowels. Separate with .*

I expect it means 2 characters...

rotten

Re: Caine Tuts - Question 3 - GREP and REGEX

Post by rotten » Thu Oct 09, 2014 9:03 pm

Greetings,

I've managed to find the correct answer with your tip! Thank you very much Master Gordon! I'd never have realized it was that easy without your help :lol: !!

Although i've got a PASS on this one (i'll PM you the command and the output later), I believe I was lucky or some coincidence happened, because it's not 100% accurate since the last word returned was "sacrilegious", which doesn't respect the vowel (AEIOU) order imposed by the problem.. could we not agree on that?

Now i'm gonna waste the next month figuring the next one out ^__^
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.

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 - Question 3 - GREP and REGEX

Post by drgrussell » Fri Oct 10, 2014 8:53 am

sacrilegious
a e iou

Seems fine to me.
I didnt say that it could only have 5 vowels in total, only that 5 appeared in order...
Gordon.

blackbee045

Re: Caine Tuts - Question 3 - GREP and REGEX

Post by blackbee045 » Thu Oct 16, 2014 8:32 pm

i just wanna know: what am i missing :?: Which one is closer: the 1st or the 2nd approach?

#2 - How many words can you find which contain any two characters repeated three times, like the examples "interlinking" and "priestessess".

About the problem #2, i've already asked about it in Linux forums. I just want to point a minor mistake on check button of this question.. it reads:
Three character string appears 3 times (takes a few seconds)

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

Re: Caine Tuts - Question 3 - GREP and REGEX

Post by drgrussell » Fri Oct 17, 2014 9:05 am

Hi.

What I am saying is [^aeiou] or anything similar is incorrect, as it assumes the characters in between are not vowels themselves, and this is not something asked for in the question.
Rather than [^aeiou], how about .* ?
You are also confused by "*". You have one right at the start, but "*" operates on the character before it, so that makes no sense.

Your other question was answered in this topic...
I expect it means 2 characters...
I will fix the wording though.
Gordon.

rotten

Re: Caine Tuts - Question 3 - GREP and REGEX

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

Greetings, Mr G.

Now it reads:
Three character string appears 2 times (takes a few seconds)
Since the question starts with:
The word interlinking includes the same two characters (e.g. "in") which appear three times.
Wouldn't the correct be --> Two character string appears 3 times?

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 - Question 3 - GREP and REGEX

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

Yes. Its not been my best day...
I will fix this next week...
G.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests