Implement a function called minimum_coin_permutations that calculates the minimum number of coin swaps required to transform a given permutation of coins into a target permutation. The function should also return the specific operations (swap indices) required to perform this transformation.
Functionality
Input Parameters:
n (int): The number of coins (length of the lists).
p (list of int): The current permutation of coins, where each integer represents a distinct coin ID.
s (list of int): The target permutation of coins that needs to be achieved.
Output:
Returns a tuple containing:
min_coins (int): The minimum number of swaps needed to convert permutation p to permutation s.
operations (list of tuple): A list of tuples representing the actual swap operations performed. Each tuple contains two integers (i, j), which are the 1-based indices of the coins that are swapped.
Input/Output Requirements
Input:
The function takes three parameters:
An integer n (1 <= n <= 1000).
A list p of length n containing integers representing the current permutation of coins (coin IDs).
A list s of length n containing integers representing the target permutation of coins (coin IDs).
Output:
The function must return a tuple (min_coins, operations) where min_coins is an integer and operations is a list of tuples.
Implementation
You must implement the function in a file called /app/solution.py. Ensure that your implementation correctly follows the described input/output format and adheres to the functionality outlined above.