StringTools[HammingDistance] - compute the Hamming distance between two strings
|
Calling Sequence
|
|
HammingDistance( s, t )
|
|
Parameters
|
|
s
|
-
|
Maple string
|
t
|
-
|
Maple string
|
|
|
|
|
Description
|
|
•
|
The HammingDistance(s,t) command returns an integer measure of the distance between the two strings s and t.
|
•
|
The Hamming distance between two strings s and t, of equal length, is the number of character positions where they differ. If strings s and t have respective lengths m and n where, without loss of generality, , then the generalized Hamming distance between s and t is defined to be (m - n) + HammingDistance( s[ 1 .. n ], t ). The HammingDistance procedure computes this generalized metric.
|
|
|
Examples
|
|
>
|
|
| (1) |
>
|
|
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
Since it is a metric, the Hamming distance satisfies the triangle inequality.
>
|
|
>
|
|
>
|
|
>
|
|
| (6) |
>
|
|
| (7) |
|
|
Download Help Document
Was this information helpful?