From: Martin Hansen Date: 2011-03-08T00:47:44+09:00 Subject: Hamming Distance What is the fastest way to calculate the Hamming Distance between two equally long strings in Ruby? A have looked at the amatch gem, but I was wondering what can be done with Ruby only? Here is a very interesting discussion on the subject: http://www.perlmonks.org/?node_id=500235 Note the elegant and extremely fast Perl solution: sub hd { return ($_[0] ^ $_[1]) =~ tr/\001-\255//; } Cheers, Martin -- Posted via http://www.ruby-forum.com/.