/**
 * This function takes a zoologist's list of animals and an animal name as arguments.
 * It returns the index of the first occurrence of the given animal in the list,
 * or -1 if the animal is not found. The zoologist's list is modified during the search
 * to remove any occurrences of the animal found during the search.
 */
fun findAnimalIndex(zoologist: MutableList<Int>, animal: Int): Int {

    val n = zoologist.size  // Get the initial length of the list

    var i = 0  // Initialize the current index

    while (i < n) {  // Iterate through the list
        if (zoologist[i] != animal) {  // Check if the animal is not equal to the current element
            i++  // Move to the next element
        } else {  // If the animal is found
            zoologist[i]--  // Subtract 1 from the current element
            return i  // Return the index of the found animal
        }
    }

    return -1  // Return -1 if the animal is not found
}
/**
 * This function takes a zoologist's list of animals and an animal name as arguments.
 * It returns the index of the first occurrence of the given animal in the list,
 * or -1 if the animal is not found. The zoologist's list is modified during the search
 * to remove any occurrences of the animal found during the search.
 */
fun findAnimalIndex(zoologist: MutableList<Int>, animal: Int): Int {
/**
 * This function takes a zoologist's list of animals and an animal name as arguments.
 * It returns the index of the first occurrence of the given animal in the list,
 * or -1 if the animal is not found. The zoologist's list is modified during the search
 * to remove any occurrences of the animal found during the search.
 */
fun findAnimalIndex(zoologist: MutableList<Int>, animal: Int): Int {

    val n = zoologist.size  // Get the initial length of the list

    var i = 0  // Initialize the current index

    while (i < n) {  // Iterate through the list
        if (zoologist[i] != animal) {  // Check if the animal is not equal to the current element
            i++  // Move to the next element
        } else {  // If the animal is found
            zoologist[i]--  // Subtract 1 from the current element
            return i  // Return the index of the found animal
        }
    }

    return -1  // Return -1 if the animal is not found
}