Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Detecting transpositions

by Abigail-II (Bishop)
on Aug 06, 2003 at 15:52 UTC ( #281457=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Detecting transpositions
in thread Detecting transpositions

That doesn't return the index of where the transposition happens, does it?


Replies are listed 'Best First'.
Re: Re: Detecting transpositions
by Cine (Friar) on Aug 06, 2003 at 16:39 UTC
    So here it is with bonus, just a little longer... And now, its just a little faster than yours. Except on large identical strings where it is 3 times faster because of the first line. Without it the regexp would perform very slow.
    sub comp { return -1 if $_[0] eq $_[1]; local $_ = $_[0] ^ $_[1]; /^([\x00]*)([^\x00])\2[\x00]*$/; $1 ? length$1 : -1; }

    T I M T O W T D I
Re: Re: Detecting transpositions
by Cine (Friar) on Aug 06, 2003 at 16:21 UTC
    No, that was only a bonus ;)

    T I M T O W T D I

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://281457]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2022-10-06 20:00 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (28 votes). Check out past polls.