/**
 * Given a string 'name' and a larger string 'text', write a function that finds all occurrences of the 'name' within the 'text' using loops and the method 'indexOf'.
 *
 * @param name The name of the animal to find.
 * @param text The larger string to search for occurrences of the name.
 * @return A list of indices where the animal name is found within the text.
 */
fun findAnimal(name: String, text: String): List<Int> {

    val indices = mutableListOf<Int>()
    var startIndex = 0

    while (true) {
        val index = text.indexOf(name, startIndex)
        if (index != -1) {
            indices.add(index)
            startIndex = index + 1  // Move the start index to the next character after the found occurrence
        } else {
            break
        }
    }

    return indices
}
/**
 * Given a string 'name' and a larger string 'text', write a function that finds all occurrences of the 'name' within the 'text' using loops and the method 'indexOf'.
 *
 * @param name The name of the animal to find.
 * @param text The larger string to search for occurrences of the name.
 * @return A list of indices where the animal name is found within the text.
 */
fun findAnimal(name: String, text: String): List<Int> {
/**
 * Given a string 'name' and a larger string 'text', write a function that finds all occurrences of the 'name' within the 'text' using loops and the method 'indexOf'.
 *
 * @param name The name of the animal to find.
 * @param text The larger string to search for occurrences of the name.
 * @return A list of indices where the animal name is found within the text.
 */
fun findAnimal(name: String, text: String): List<Int> {

    val indices = mutableListOf<Int>()
    var startIndex = 0

    while (true) {
        val index = text.indexOf(name, startIndex)
        if (index != -1) {
            indices.add(index)
            startIndex = index + 1  // Move the start index to the next character after the found occurrence
        } else {
            break
        }
    }

    return indices
}