/**
 * Given a dictionary representing a farmer's farm with nested dictionaries of crops and their quantities,
 * calculate the total produce of all crops.
 *
 * @param farm A dictionary representing the farmer's farm with nested dictionaries.
 * @return The total produce of all crops on the farm.
 */
fun calculateTotalProduce(farm: Map<String, Map<String, Int>>): Int {

    var totalProduce = 0

    // Iterate over each crop in the farm
    for (field in farm.values) {
        for (crop in field.values) {
            // Add the quantity of each crop to the total produce
            totalProduce += crop
        }
    }

    return totalProduce
}

val farm = mapOf(
    "field1" to mapOf(
        "corn" to 50,
        "wheat" to 20,
        "potatoes" to 100
    ),
    "field2" to mapOf(
        "soybeans" to 80,
        "wheat" to 40,
        "carrots" to 60
    ),
    "field3" to mapOf(
        "corn" to 30,
        "carrots" to 40,
        "wheat" to 10
    )
)

// Calculate the total produce of all crops on the farm
val totalProduce = calculateTotalProduce(farm)
/**
 * Given a dictionary representing a farmer's farm with nested dictionaries of crops and their quantities,
 * calculate the total produce of all crops.
 *
 * @param farm A dictionary representing the farmer's farm with nested dictionaries.
 * @return The total produce of all crops on the farm.
 */
fun calculateTotalProduce(farm: Map<String, Map<String, Int>>): Int {
/**
 * Given a dictionary representing a farmer's farm with nested dictionaries of crops and their quantities,
 * calculate the total produce of all crops.
 *
 * @param farm A dictionary representing the farmer's farm with nested dictionaries.
 * @return The total produce of all crops on the farm.
 */
fun calculateTotalProduce(farm: Map<String, Map<String, Int>>): Int {

    var totalProduce = 0

    // Iterate over each crop in the farm
    for (field in farm.values) {
        for (crop in field.values) {
            // Add the quantity of each crop to the total produce
            totalProduce += crop
        }
    }

    return totalProduce
}

val farm = mapOf(
    "field1" to mapOf(
        "corn" to 50,
        "wheat" to 20,
        "potatoes" to 100
    ),
    "field2" to mapOf(
        "soybeans" to 80,
        "wheat" to 40,
        "carrots" to 60
    ),
    "field3" to mapOf(
        "corn" to 30,
        "carrots" to 40,
        "wheat" to 10
    )
)

// Calculate the total produce of all crops on the farm
val totalProduce = calculateTotalProduce(farm)