/**
 * This function takes a list of dancers' names, a string representing the first letters of the desired dancer's name,
 * and a boolean indicating whether the desired dancer is currently dancing or not. It returns the index of the dancer
 * who matches the given criteria.
 *
 * @param dancers a list of strings representing dancers' names
 * @param nameStartsWith a string representing the desired first letters of the dancer's name
 * @param isDancing a boolean indicating whether the desired dancer is currently dancing or not
 * @return Index of the dancer who matches the given criteria (integer). If no dancer matches, returns -1.
 *
 * Example:
 * findDancer(listOf("Alice", "Bob", "Carl", "David", "Eva"), "Da", true) returns 3, as "David" is the 4th dancer in the list and
 * begins with "Da" and is currently dancing.
 */
fun findDancer(dancers: List<String>, nameStartsWith: String, isDancing: Boolean): Int {

    for ((index, dancer) in dancers.withIndex()) {
        if (isDancing && dancer.startsWith(nameStartsWith)) {
            return index
        }
    }
    return -1
}
/**
 * This function takes a list of dancers' names, a string representing the first letters of the desired dancer's name,
 * and a boolean indicating whether the desired dancer is currently dancing or not. It returns the index of the dancer
 * who matches the given criteria.
 *
 * @param dancers a list of strings representing dancers' names
 * @param nameStartsWith a string representing the desired first letters of the dancer's name
 * @param isDancing a boolean indicating whether the desired dancer is currently dancing or not
 * @return Index of the dancer who matches the given criteria (integer). If no dancer matches, returns -1.
 *
 * Example:
 * findDancer(listOf("Alice", "Bob", "Carl", "David", "Eva"), "Da", true) returns 3, as "David" is the 4th dancer in the list and
 * begins with "Da" and is currently dancing.
 */
fun findDancer(dancers: List<String>, nameStartsWith: String, isDancing: Boolean): Int {
/**
 * This function takes a list of dancers' names, a string representing the first letters of the desired dancer's name,
 * and a boolean indicating whether the desired dancer is currently dancing or not. It returns the index of the dancer
 * who matches the given criteria.
 *
 * @param dancers a list of strings representing dancers' names
 * @param nameStartsWith a string representing the desired first letters of the dancer's name
 * @param isDancing a boolean indicating whether the desired dancer is currently dancing or not
 * @return Index of the dancer who matches the given criteria (integer). If no dancer matches, returns -1.
 *
 * Example:
 * findDancer(listOf("Alice", "Bob", "Carl", "David", "Eva"), "Da", true) returns 3, as "David" is the 4th dancer in the list and
 * begins with "Da" and is currently dancing.
 */
fun findDancer(dancers: List<String>, nameStartsWith: String, isDancing: Boolean): Int {

    for ((index, dancer) in dancers.withIndex()) {
        if (isDancing && dancer.startsWith(nameStartsWith)) {
            return index
        }
    }
    return -1
}