/**
 * In this exercise, you are given a list of chef names and a list of ingredients.
 * You need to iterate over the chef names and replace each occurrence of the word 'cooking'
 * in the ingredients list with the respective chef's name, then slice the chef's name
 * starting from the 2nd character and append it to a new list called 'result'.
 * If the chef's name is longer than 4 characters, you should break out of the loop.
 * Finally, return the 'result' list.
 */
fun sliceAndReplace(chefNames: List<String>, ingredients: MutableList<String>): List<String> {

    val result = mutableListOf<String>()
    for (chefName in chefNames) {
        for (i in ingredients.indices) {
            if ("cooking" in ingredients[i]) {
                ingredients[i] = ingredients[i].replace("cooking", chefName)
            }
            if (chefName.length > 4) {
                break
            }
        }
        result.add(chefName.substring(1))
    }
    return result
}
/**
 * In this exercise, you are given a list of chef names and a list of ingredients.
 * You need to iterate over the chef names and replace each occurrence of the word 'cooking'
 * in the ingredients list with the respective chef's name, then slice the chef's name
 * starting from the 2nd character and append it to a new list called 'result'.
 * If the chef's name is longer than 4 characters, you should break out of the loop.
 * Finally, return the 'result' list.
 */
fun sliceAndReplace(chefNames: List<String>, ingredients: MutableList<String>): List<String> {
/**
 * In this exercise, you are given a list of chef names and a list of ingredients.
 * You need to iterate over the chef names and replace each occurrence of the word 'cooking'
 * in the ingredients list with the respective chef's name, then slice the chef's name
 * starting from the 2nd character and append it to a new list called 'result'.
 * If the chef's name is longer than 4 characters, you should break out of the loop.
 * Finally, return the 'result' list.
 */
fun sliceAndReplace(chefNames: List<String>, ingredients: MutableList<String>): List<String> {

    val result = mutableListOf<String>()
    for (chefName in chefNames) {
        for (i in ingredients.indices) {
            if ("cooking" in ingredients[i]) {
                ingredients[i] = ingredients[i].replace("cooking", chefName)
            }
            if (chefName.length > 4) {
                break
            }
        }
        result.add(chefName.substring(1))
    }
    return result
}