/**
 * Chef's task is to cook a recipe with provided ingredients.
 * The recipe requires precision in measurement and rounding of floating-point numbers.
 * Your task is to implement the cookRecipe function.
 The function should take a list of ingredients and return the time needed to cook the recipe.
 *
 * @param ingredients A list of pairs containing the ingredient name and amount in grams.
 * @return The time needed to cook the recipe in minutes.
 */
fun cookRecipe(ingredients: List<Pair<String, Double>>): Int {

    // Check if the ingredients are provided
    if (ingredients.isEmpty()) {
        println("No ingredients provided.")
        return 0
    }

    // Initialize the total cook time
    var cookTime = 0

    // Iterate over each ingredient
    for ((ingredient, amount) in ingredients) {
        // Determine the cooking time for the ingredient
        when (ingredient) {
            "flour", "sugar" -> cookTime += (amount / 100).toInt() // Cook flour and sugar for 1 minute per 100 grams rounded to the nearest integer
            "salt" -> TODO("Cooking time for salt is not specified.")
            else -> println("Unknown ingredient: $ingredient")
        }
    }

    return cookTime
}
/**
 * Chef's task is to cook a recipe with provided ingredients.
 * The recipe requires precision in measurement and rounding of floating-point numbers.
 * Your task is to implement the cookRecipe function.
 The function should take a list of ingredients and return the time needed to cook the recipe.
 *
 * @param ingredients A list of pairs containing the ingredient name and amount in grams.
 * @return The time needed to cook the recipe in minutes.
 */
fun cookRecipe(ingredients: List<Pair<String, Double>>): Int {
/**
 * Chef's task is to cook a recipe with provided ingredients.
 * The recipe requires precision in measurement and rounding of floating-point numbers.
 * Your task is to implement the cookRecipe function.
 The function should take a list of ingredients and return the time needed to cook the recipe.
 *
 * @param ingredients A list of pairs containing the ingredient name and amount in grams.
 * @return The time needed to cook the recipe in minutes.
 */
fun cookRecipe(ingredients: List<Pair<String, Double>>): Int {

    // Check if the ingredients are provided
    if (ingredients.isEmpty()) {
        println("No ingredients provided.")
        return 0
    }

    // Initialize the total cook time
    var cookTime = 0

    // Iterate over each ingredient
    for ((ingredient, amount) in ingredients) {
        // Determine the cooking time for the ingredient
        when (ingredient) {
            "flour", "sugar" -> cookTime += (amount / 100).toInt() // Cook flour and sugar for 1 minute per 100 grams rounded to the nearest integer
            "salt" -> TODO("Cooking time for salt is not specified.")
            else -> println("Unknown ingredient: $ingredient")
        }
    }

    return cookTime
}