mirror of
https://github.com/duke-git/lancet.git
synced 2026-03-01 00:35:28 +08:00
Strutil: HammingDistance func
The Hamming distance is the number of positions at which the corresponding symbols are different
This commit is contained in:
@@ -667,3 +667,16 @@ func ExampleSubInBetween() {
|
||||
// abc
|
||||
// bc
|
||||
}
|
||||
|
||||
func ExampleHammingDistance() {
|
||||
|
||||
result, _ := HammingDistance("abc", "def")
|
||||
fmt.Println(result)
|
||||
|
||||
result, _ = HammingDistance("name", "namf")
|
||||
fmt.Println(result)
|
||||
|
||||
// Output:
|
||||
// 3
|
||||
// 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user