Is there any recursive way to implement minimum number of adjacent swaps to convert a string into its given anagram in particular this solution?
I have written a solution in Python but I don't know how to implement it using recursion.
def min_adjacent_swaps(r1, r2):
    s1 = list(r1)
    s2 = list(r2)
    i = 0
    j = 0
    result = 0
    while i < len(s2):
        j = i
        while s1[j] != s2[i]:
            j += 1
        while i < j:
            temp = s1[j]
            s1[j] = s1[j - 1]
            s1[j - 1] = temp
            j -= 1
            result += 1
        i += 1
    return result
>>> print(min_adjacent_swaps("abcd", "badc"))
2
 
    