/**
 * This function takes a farmer's name and a dictionary of crops and appends the crops to the
 * farmer's list of crops.
 *
 * @param farmer The name of the farmer.
 * @param cropsDict A dictionary where the keys are crops and the values are quantities.
 * @return A list containing all the crops of the farmer after appending.
 */
fun addCropsToList(farmer: String, cropsDict: Map<String, Int>): List<String> {

    // Initialize an empty list to store the farmer's crops
    val farmerCrops = mutableListOf<String>()

    // Iterate over the dictionary items
    for ((crop, quantity) in cropsDict) {
        // Append the crop to the farmer's crops list 'quantity' number of times
        farmerCrops.addAll(List(quantity) { crop })
    }

    // Return the updated list of crops for the farmer
    return farmerCrops
}
/**
 * This function takes a farmer's name and a dictionary of crops and appends the crops to the
 * farmer's list of crops.
 *
 * @param farmer The name of the farmer.
 * @param cropsDict A dictionary where the keys are crops and the values are quantities.
 * @return A list containing all the crops of the farmer after appending.
 */
fun addCropsToList(farmer: String, cropsDict: Map<String, Int>): List<String> {
/**
 * This function takes a farmer's name and a dictionary of crops and appends the crops to the
 * farmer's list of crops.
 *
 * @param farmer The name of the farmer.
 * @param cropsDict A dictionary where the keys are crops and the values are quantities.
 * @return A list containing all the crops of the farmer after appending.
 */
fun addCropsToList(farmer: String, cropsDict: Map<String, Int>): List<String> {

    // Initialize an empty list to store the farmer's crops
    val farmerCrops = mutableListOf<String>()

    // Iterate over the dictionary items
    for ((crop, quantity) in cropsDict) {
        // Append the crop to the farmer's crops list 'quantity' number of times
        farmerCrops.addAll(List(quantity) { crop })
    }

    // Return the updated list of crops for the farmer
    return farmerCrops
}