re and permutation

G

giampiero mu

hi

i'm newbie with re.
i have a problem:
given a function f(a,b) that gives true if a is a permutated string of
b.
i have to write a re in which we test if given a string l, a and b (not
overlapping) are present using f. In other words a re that inglobe f.
thanking everyone for help.

giampiero
 
À

शंतनॠमहाजन (Shantanoo Mahajan

You can use hash for this. For each character as key of the hash, and
value equal to the number of occurance. Do this for both strings. And
then compare the values.
 
W

William James

giampiero said:
hi

i'm newbie with re.
i have a problem:
given a function f(a,b) that gives true if a is a permutated string of
b.
i have to write a re in which we test if given a string l, a and b (not
overlapping) are present using f. In other words a re that inglobe f.
thanking everyone for help.

giampiero

Using Ruby:
'trap'.split(//).sort == 'part'.split(//).sort
=> true
 
P

Paul Lalli

Mothra said:
Why are you posting ruby code in a Perl newsgroup?

Because he's a troll. Check out all the recent postings from him.
He's hoping to start a Perl vs Ruby flamewar. Please don't encourage
the troll by responding to it.

Paul Lalli
 
X

xhoster

giampiero mu said:
hi

i'm newbie with re.
i have a problem:
given a function f(a,b) that gives true if a is a permutated string of
b.
i have to write a re in which we test if given a string l, a and b (not
overlapping) are present using f. In other words a re that inglobe f.
thanking everyone for help.


Either this is stupid homework, or it is just stupid. The function f is
not necessary or even helpful for solving this problem, so why does the
answer require its use?

Xho
 
B

borges2003xx

thanx for your courtesy.
It's only a way to learn by example how put a function f working in re.
thanx for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top