Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Detecting transpositions

by Skeeve (Parson)
on Aug 06, 2003 at 08:28 UTC ( [id://281310]=note: print w/replies, xml ) Need Help??


in reply to Detecting transpositions

print comp( 'foo', 'ofo' ) ? "True\n" : "False\n"; print comp( 'foo', 'foo' ) ? "True\n" : "False\n"; print comp( 'abcde', 'bacde' ) ? "True\n" : "False\n"; print comp( 'abcde', 'cabde' ) ? "True\n" : "False\n"; sub comp { my($x,$y)= @_; my($xreg)=join('|', grep $_,map {$1.$3.$2.$4 if $x=~ /^(.{$_})(.)(.) +(.*)/ && $2 ne $3} 0..length $x); return $y=~ /^$xreg$/; }
Update: Forget it ;-/ Abigail's is MUCH better! ++ for her him

Update: Thanks to dragonchild and perlguy for telling me that Abigail-II is a he ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found