/**
 * This exercise requires a police officer to swap the places of two individuals within a list of names.
 * The function takes three arguments:
 * - name1: a string representing the first name to be swapped
 * - name2: a string representing the second name to be swapped
 * - names: a list of strings representing the names of the individuals
 *
 * The function should locate the positions of name1 and name2 within the list and interchange their places.
 * The updated list of names should be returned as the output.
 *
 * Example:
 * swapPlaces("Alice", "Bob", listOf("Charlie", "Alice", "David", "Bob", "Eve")) should return ["Charlie", "Bob", "David", "Alice", "Eve"]
 */
fun swapPlaces(name1: String, name2: String, names: MutableList<String>): List<String> {

    // Find the indices of name1 and name2
    val index1 = names.indexOf(name1)
    val index2 = names.indexOf(name2)

    // Swap the elements at the found indices
    names[index1] = names.set(index2, names[index1])

    return names
}
/**
 * This exercise requires a police officer to swap the places of two individuals within a list of names.
 * The function takes three arguments:
 * - name1: a string representing the first name to be swapped
 * - name2: a string representing the second name to be swapped
 * - names: a list of strings representing the names of the individuals
 *
 * The function should locate the positions of name1 and name2 within the list and interchange their places.
 * The updated list of names should be returned as the output.
 *
 * Example:
 * swapPlaces("Alice", "Bob", listOf("Charlie", "Alice", "David", "Bob", "Eve")) should return ["Charlie", "Bob", "David", "Alice", "Eve"]
 */
fun swapPlaces(name1: String, name2: String, names: MutableList<String>): List<String> {
/**
 * This exercise requires a police officer to swap the places of two individuals within a list of names.
 * The function takes three arguments:
 * - name1: a string representing the first name to be swapped
 * - name2: a string representing the second name to be swapped
 * - names: a list of strings representing the names of the individuals
 *
 * The function should locate the positions of name1 and name2 within the list and interchange their places.
 * The updated list of names should be returned as the output.
 *
 * Example:
 * swapPlaces("Alice", "Bob", listOf("Charlie", "Alice", "David", "Bob", "Eve")) should return ["Charlie", "Bob", "David", "Alice", "Eve"]
 */
fun swapPlaces(name1: String, name2: String, names: MutableList<String>): List<String> {

    // Find the indices of name1 and name2
    val index1 = names.indexOf(name1)
    val index2 = names.indexOf(name2)

    // Swap the elements at the found indices
    names[index1] = names.set(index2, names[index1])

    return names
}