Problem 846. Calculate the Hamming distance between two strings
Inspired by a similar Cody problem found here.
Parts of the problem description were taken from http://en.wikipedia.org/wiki/Hamming_distance.
The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. In other words, it is the number of substitutions required to transform one string into another. Given two strings of equal length, compute the Hamming distance.
Example
If
s1 = 'cats' s2 = 'dogs'
then
d = 3
because three substitutions are required to transform s1 into s2.
cats => dats (substitute 'd' for 'c') dats => dots (substitute 'o' for 'a') dots => dogs (substitute 'g' for 't')
Solution Stats
Problem Comments
Solution Comments
Show commentsGroup

Strings I
- 30 Problems
- 102 Finishers
- Guess Cipher
- QWERTY Shift Encoder
- Calculate a modified Levenshtein distance between two strings
- Find matching string from a list of strings
- Find matching parenthesis
- Transposition as a CIPHER
- Decimal Comparison
- Return the first and last characters of a character array
- Find Rotated Substring
- Cell Counting: How Many Draws?
- Split a string into chunks of specified length
- Ordinal numbers
- Add more zeros
- Without the French accent please!
- Calculate a modified Levenshtein distance between two strings
- Calculate the Hamming distance between two strings
- Find mistyped words in text (mixed-up letters)
- QWERTY Shift Code Decoder
- QWERTY Shift Encoder
- Convert a structure into a string
- Return the first and last characters of a character array
- String substitution, sub problem to cryptoMath
- Number of 1s in a binary string
- Transposition as a CIPHER
- Use of regexp
- Pig Latin to English Translator
- English to Pig Latin Translator
- Formatting currency numbers
- Bang Bang in Bangalore
- Compress strings (not springs)
- letter yes yes & letter no no
- Convert String to Morse Code
- Decimal Comparison
- Find matching string from a list of strings
- Find Rotated Substring
- Reverse the Words (not letters) of a String
- Space Saver
- Find matching parenthesis
Problem Recent Solvers325
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!