/**
 * This function takes a dictionary of ingredients and the name of an ingredient as input.
 * It checks if the ingredient is available in the dictionary and if it is not empty,
 * it replaces the ingredient with a new ingredient provided as input.
 *
 * @param ingredientDict A nested dictionary representing the available ingredients.
 * @param ingredientName The name of the ingredient to be replaced.
 * @return The updated dictionary of ingredients.
 */
fun prepareIngredient(ingredientDict: MutableMap<String, MutableMap<String, String>>, ingredientName: String): MutableMap<String, MutableMap<String, String>> {

    // Check if the ingredient is available in the dictionary
    if (ingredientName in ingredientDict) {
        // Check if the ingredient is empty
        if (ingredientDict[ingredientName]?.isNotEmpty() == true) {
            print("Enter the replacement ingredient: ")
            val replacementIngredient = readLine()
            ingredientDict[ingredientName] = mutableMapOf("" to replacementIngredient.orEmpty())
            return ingredientDict
        } else {
            println("The ingredient is already empty.")
        }
    } else {
        println("The ingredient is not available in the dictionary.")
    }
    return ingredientDict
}

// Example usage
val ingredientDict = mutableMapOf(
    "vegetables" to mutableMapOf(
        "carrots" to "5",
        "onions" to "2",
        "peppers" to "3"
    ),
    "meat" to mutableMapOf()
)
/**
 * This function takes a dictionary of ingredients and the name of an ingredient as input.
 * It checks if the ingredient is available in the dictionary and if it is not empty,
 * it replaces the ingredient with a new ingredient provided as input.
 *
 * @param ingredientDict A nested dictionary representing the available ingredients.
 * @param ingredientName The name of the ingredient to be replaced.
 * @return The updated dictionary of ingredients.
 */
fun prepareIngredient(ingredientDict: MutableMap<String, MutableMap<String, String>>, ingredientName: String): MutableMap<String, MutableMap<String, String>> {
/**
 * This function takes a dictionary of ingredients and the name of an ingredient as input.
 * It checks if the ingredient is available in the dictionary and if it is not empty,
 * it replaces the ingredient with a new ingredient provided as input.
 *
 * @param ingredientDict A nested dictionary representing the available ingredients.
 * @param ingredientName The name of the ingredient to be replaced.
 * @return The updated dictionary of ingredients.
 */
fun prepareIngredient(ingredientDict: MutableMap<String, MutableMap<String, String>>, ingredientName: String): MutableMap<String, MutableMap<String, String>> {

    // Check if the ingredient is available in the dictionary
    if (ingredientName in ingredientDict) {
        // Check if the ingredient is empty
        if (ingredientDict[ingredientName]?.isNotEmpty() == true) {
            print("Enter the replacement ingredient: ")
            val replacementIngredient = readLine()
            ingredientDict[ingredientName] = mutableMapOf("" to replacementIngredient.orEmpty())
            return ingredientDict
        } else {
            println("The ingredient is already empty.")
        }
    } else {
        println("The ingredient is not available in the dictionary.")
    }
    return ingredientDict
}

// Example usage
val ingredientDict = mutableMapOf(
    "vegetables" to mutableMapOf(
        "carrots" to "5",
        "onions" to "2",
        "peppers" to "3"
    ),
    "meat" to mutableMapOf()
)