Lily's Homework

  • + 0 comments

    I came up with a similar but not exactly the same approach in which i just counted mismatches and thought to apply some function on mismatches that would directly give swaps:

    if mismatches%2:
        return mismatches//2 + 1
    else:
        return mismatches//2
    

    But it somehow fails test case 1, 2, 3, 6. In the end I decided to go with actually swapping and counting it

    Isn't there any such function that could direcly be applied on mismatch count to yield number of swaps?