Haskell, 192 181 174 161 158 150 147 143143 1581 bytes
e@(a:r)&f@(b:s)=snd$maximum[([1|' '<-s!!2],s)|s<-z(z(:))[a:" R",' ':b:"A",a:b:last("M":[" "|a==b])][r&f,e&s,r&s]] x&y=[x,y,x++y>>"R"]"RA"!!(0^length x)<$x++y] z=zipWith
Try it online! Example usage: "ABCDEF" & "AFBECD". Returns a list of three strings. This is an extension of my recursive solution to the ordinary Levenshtein distance question.
###Explanation: To compute the minimal modifications to get from "xyz" to "yw", we focus on the first character of both strings. There are three possibilities:
- Remove: Drop
x from the first string and recursively compute the modifications to get from "yz" to "yw". This yields the three lines ["yz","yw"," M"]. Add x to the first one, a space to the second one and R to the third one. We get xyz yw R M
- Add: Drop
y from the second string and compute "xyz" & "w", which returns the result ["xyz","w","MRR"]. We need to add a space on the first line, y to the second and A to the third line: xyz yw AMRR
- Modified/Unchanged: We can combine those two cases because both require to drop the first character of both strings and compute the minimal modifications between the remaining strings:
"yz" & "w". To the result ["yz","w","MR"], we add x on he first and y on the second line. Only for the last line we need to differentiate whether the initial characters are the same. If they are the same, a space is added to the third line, otherwise (as in this case because x \= y) an M is added: xyz yw MMR
From those three candidates, we need to find the one with the fewest modifications. This is equivalent to having the most spaces on the third line. Therefore we convert each candidate s (a list of three strings) to a tuple ([1|' '<-s!!2],s), where s appears as second component and the first component is a list with as many elements as there are spaces in the third line of s (s!!2 because of 0-indexing). As list element 1 is used, but the actual element is irrelevant as long as it is the same for all candidates.
Altogether, this yields the list of tuples
[([1],["xyz"," yw","R M"]),([],[" xyz","yw","AMRR"]),([],["xyz","yw","MMR"])]
The build-inmaximum selects the largest element of this list, where tuples are compared lexicographically, that is component-wise from left to right. As[1] is larger than[], the first tuple is selected, andsnd returns the second of component, that is the list of lines, of the tuple.
1 +15 bytes to fix a bug where A-changes at the end of a string would be displayed as R-changes