ULM4MAJVZT7O4VXUP536NABOPIDEH5UIVJFOKDQWO6ZEB62TDM6QC
/*
Package hamming is for calculating Hamming distance
*/
package hamming
import "errors"
// Distance will calculate the hamming distance of the two input string.
// Returns the distance, sets error if something goes wrong.
func Distance(a, b string) (int, error) {
var hamming int
if len(a) != len(b) {
return 0, errors.New("hamming: the two sting lenght is not equal")
}
for k := range a {
if a[k] != b[k] {
hamming++
}
}
return hamming, nil
}