/**
 * Given a list of pets, calculate the average weight of all dogs and cats.
 *
 * @param petList A list of dictionaries containing pet information.
 * @return Average weight of dogs and cats.
 */
fun calculateAverageWeight(petList: List<Map<String, Any>>): Double {

    var dogCount = 0
    var dogWeightSum = 0.0
    var catCount = 0
    var catWeightSum = 0.0

    for (pet in petList) {
        val species = pet["species"] as String
        val weight = pet["weight"] as Double

        when (species) {
            "dog" -> {
                dogCount++
                dogWeightSum += weight
            }
            "cat" -> {
                catCount++
                catWeightSum += weight
            }
            else -> {
                // Handle other species separately if needed
            }
        }
    }

    val dogAverageWeight = if (dogCount != 0) dogWeightSum / dogCount else 0.0
    val catAverageWeight = if (catCount != 0) catWeightSum / catCount else 0.0

    return (dogAverageWeight + catAverageWeight) / 2
}
/**
 * Given a list of pets, calculate the average weight of all dogs and cats.
 *
 * @param petList A list of dictionaries containing pet information.
 * @return Average weight of dogs and cats.
 */
fun calculateAverageWeight(petList: List<Map<String, Any>>): Double {
/**
 * Given a list of pets, calculate the average weight of all dogs and cats.
 *
 * @param petList A list of dictionaries containing pet information.
 * @return Average weight of dogs and cats.
 */
fun calculateAverageWeight(petList: List<Map<String, Any>>): Double {

    var dogCount = 0
    var dogWeightSum = 0.0
    var catCount = 0
    var catWeightSum = 0.0

    for (pet in petList) {
        val species = pet["species"] as String
        val weight = pet["weight"] as Double

        when (species) {
            "dog" -> {
                dogCount++
                dogWeightSum += weight
            }
            "cat" -> {
                catCount++
                catWeightSum += weight
            }
            else -> {
                // Handle other species separately if needed
            }
        }
    }

    val dogAverageWeight = if (dogCount != 0) dogWeightSum / dogCount else 0.0
    val catAverageWeight = if (catCount != 0) catWeightSum / catCount else 0.0

    return (dogAverageWeight + catAverageWeight) / 2
}