re and permutation

Discussion in 'Perl Misc' started by giampiero mu, Aug 10, 2005.

  1. giampiero mu

    giampiero mu Guest

    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
     
    giampiero mu, Aug 10, 2005
    #1
    1. Advertising

  2. 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.
     
    शंतनॠमहाजन (Shantanoo Mahajan, Aug 10, 2005
    #2
    1. Advertising

  3. giampiero mu wrote:
    > 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
     
    William James, Aug 10, 2005
    #3
  4. giampiero mu

    Mothra Guest

    William James wrote:
    > Using Ruby:
    > 'trap'.split(//).sort == 'part'.split(//).sort
    > => true

    Why are you posting ruby code in a Perl newsgroup?

    Mothra
     
    Mothra, Aug 10, 2005
    #4
  5. giampiero mu

    Paul Lalli Guest

    Mothra wrote:
    > William James wrote:
    > > Using Ruby:
    > > 'trap'.split(//).sort == 'part'.split(//).sort
    > > => true

    > 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
     
    Paul Lalli, Aug 10, 2005
    #5
  6. giampiero mu

    Guest

    "giampiero mu" <> wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Aug 11, 2005
    #6
  7. giampiero mu

    Guest

    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
     
    , Aug 12, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger B.
    Replies:
    13
    Views:
    616
    D.F.S.
    Sep 26, 2003
  2. m sergei
    Replies:
    4
    Views:
    11,172
    Philip Parker
    Jun 29, 2004
  3. Sriram Rajagopalan

    String Permutation function in C

    Sriram Rajagopalan, Oct 29, 2003, in forum: C Programming
    Replies:
    7
    Views:
    13,218
  4. Talin

    Permutation Generator

    Talin, Aug 12, 2005, in forum: Python
    Replies:
    10
    Views:
    15,067
    Gerard Flanagan
    Aug 15, 2005
  5. fadliwdt

    [help] String permutation with input

    fadliwdt, Nov 17, 2006, in forum: C Programming
    Replies:
    0
    Views:
    435
    fadliwdt
    Nov 17, 2006
Loading...

Share This Page