I need an algorithm that calculates something similar to Levenshtein distance. He must calculate the minimum possible number of transformations in order to move from one sequence to another. Allowed conversions are to delete, insert, and move:
Delete 3: before {1, 2, 3, 4}, after {1, 2, 4}
Box 5: before {1, 2, 3, 4}, after {1, 2, 5, 3, 4}
Move 4: before {1, 2, 3, 4}, after {4, 1, 2, 3}
Thus, the algorithm should calculate the minimum number of such transformations, taking into account the initial and final sequence of numbers and, ideally, give a list of necessary transformations. One important feature of sequences is that the number is never duplicated.
I have an idea that I can modify the Levenshtein algorithm, so it only considers the number of deletions and inserts and ignores the substitutions. And the number of moves will be the number of deletions plus the number of attachments divided by 2. But I'm not sure if this is correct.
Does anyone know such an algorithm?
EDIT:
I probably should have said that this algorithm would work on a sequence of sequences. For example:
{{1, 2, 3}, {4}, {5, 6, 7}}
where the numbers are not duplicated. The total number of internal elements in the sequence does not change. Elements can migrate from one inner sequence to another inner sequence. The number of internal sequences is also constant. So it could be
{{1, 2, 3, 4, 5, 6, 7}, {}, {}}
{{}, {1, 2, 3, 4, 5, 6, 7}, {}}
{{}, {}, {1, 2, 3, 4, 5, 6, 7}}
, , , .
, , .
, MINIMAL . - .