1. What if we replace Line 4 by
di
:= 5
ni?
2. There are simpler schemes that can detect a single substitution error than the one in cc-check: for example, we could simply ensure that the sum of all the digits themselves (undoubted) is divisible by 10. (Just skip the doubling step.) The credit-card encoding system includes the more complicated doubling step to help it detect a different type of error, called a transposition error, where two adjacent digits are recorded in reverse order. (If two digits are swapped, then the “wrong” digit is multiplied by two, and so this kind of error might be detectable.) Does cc-check detect every possible transposition error?
A metric space consists of a set X and a function d : X × X → R≥0 , called a distance function, where d obeys the following three properties:
• reflexivity: for any x and y in X, we have d(x, x) = 0, and d(x, y) 6= 0 whenever x 6= y.
• symmetry: for any x, y ∈ X, we have d(x, y) = d(y, x).
• triangle inequality: for any x, y, z ∈ X, we have d(x, y) ≤ d(x, z) + d(z, y).