I am interested in a function from two lists of words that return the distance from the agnostic order between them.
That is, the arguments will be two lists of words (let’s say, limited by space), and the return value will be the minimum sum of the editing distances (or Levenshtein) of the words in the lists.
The distance between "cat rat bat"and "rat bat cat"will be 0. The distance between "cat rat bat"and "fat had bad"will be the same as the distance between "rat bat cat"and "had fat bad", 4. In case the number of words in the lists does not match, the shorter list will be supplemented with words of length 0.
My intuition (which was not brought up with the help of computer science classes) does not find any other solution than using brute force:
|had|fat|bad| a solution
---+---+---+---+ +---+---+---+
cat| 2 | 1 | 2 | | | 1 | |
---+---+---+---+ +---+---+---+
rat| 2 | 1 | 2 | | 3 | | |
---+---+---+---+ +---+---+---+
bat| 2 | 1 | 1 | | | | 4 |
---+---+---+---+ +---+---+---+
, , , . , .
. ?