Hm, good point. Probably something like the edit distance, but with the preference to keep the prefix and suffix to make the ids readable. So one simple algorithm would optimize the sum of edit distances under the constraint that the ids have to be unique.