Re: AW: mini-golf: first differing position
Xavier Noria <[email protected]>
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
On Apr 21, 2004, at 8:40, Winter Christian wrote:
> No, this one also counts similarities after the first differing
> character.
> $x = "abcfff"; $y = "abcggg";
> correctly gives 3, but just try out
> $x = "abcfff"; $y = "abcgff";
> which gives you 5 because of the matching "f"s.
>
> This way it should work:
> $_=$x^$y; $n=s/[^\0]//?$-[0]:()
Good. With a little modification we get 26 if this is right:
$_=$x^$y;$n=$-[0]if/[^\0]/
-- fxn