Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^4: Hamming Distance Between 2 Strings - Fast(est) Way?by BrowserUk (Patriarch) |
on Jul 08, 2011 at 19:46 UTC ( [id://913409]=note: print w/replies, xml ) | Need Help?? |
^ in this case is bitwise-OR. When you bitwise-OR two strings, where the bytes in the two strings are the same, the byte in the resultant string will be chr(0); when they are different, the results will be non-chr(0). This allows you to count the number of differences in two strings very quickly:
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|