I’m not sure I’ve titled this post correctly, but I’m wondering if there’s a name for this type of algorithm:
What I’m trying to accomplish is to create a minimal set of instructions to go from one string to its permutation, so for example:
STACKOVERFLOW -> STAKCOVERFLOW
would require a minimum of one operation, which is to
shift K before C.
Are there any good online examples of
- Finding the minimum instruction set (I believe this is also often called the edit distance), and
- Listing the instruction set
Thanks!
There is something known as the Levenshtein distance that tells you how many changes are needed to go from one string to another and there are many C# implementations, many other languages too.
Here’s the wiki:
http://en.wikipedia.org/wiki/Levenshtein_distance
Edit: As TheHorse has indicated, the Levenshtein distance doesn’t understand Shift changes, but there is an improved algorithm:
Damerau-Levenshtein distance