/**
 * Given two lists of integers, modify the elements in list1 based on the following rules:
 * 1. If an element in list1 is divisible by 3, add the corresponding element in list2 to it.
 * 2. If an element in list1 is divisible by 5, subtract the corresponding element in list2 from it.
 * 3. If an element in list1 is divisible by both 3 and 5, multiply it by the corresponding element in list2.
 *
 * @param list1 List of integers
 * @param list2 List of integers
 * @return Modified list1 according to the rules mentioned above
 */
fun modifyingListElements(list1: MutableList<Int>, list2: List<Int>): List<Int> {

    for (i in list1.indices) {
        when {
            list1[i] % 3 == 0 && list1[i] % 5 == 0 -> list1[i] *= list2[i]
            list1[i] % 3 == 0 -> list1[i] += list2[i]
            list1[i] % 5 == 0 -> list1[i] -= list2[i]
        }
    }
    return list1
}
/**
 * Given two lists of integers, modify the elements in list1 based on the following rules:
 * 1. If an element in list1 is divisible by 3, add the corresponding element in list2 to it.
 * 2. If an element in list1 is divisible by 5, subtract the corresponding element in list2 from it.
 * 3. If an element in list1 is divisible by both 3 and 5, multiply it by the corresponding element in list2.
 *
 * @param list1 List of integers
 * @param list2 List of integers
 * @return Modified list1 according to the rules mentioned above
 */
fun modifyingListElements(list1: MutableList<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists of integers, modify the elements in list1 based on the following rules:
 * 1. If an element in list1 is divisible by 3, add the corresponding element in list2 to it.
 * 2. If an element in list1 is divisible by 5, subtract the corresponding element in list2 from it.
 * 3. If an element in list1 is divisible by both 3 and 5, multiply it by the corresponding element in list2.
 *
 * @param list1 List of integers
 * @param list2 List of integers
 * @return Modified list1 according to the rules mentioned above
 */
fun modifyingListElements(list1: MutableList<Int>, list2: List<Int>): List<Int> {

    for (i in list1.indices) {
        when {
            list1[i] % 3 == 0 && list1[i] % 5 == 0 -> list1[i] *= list2[i]
            list1[i] % 3 == 0 -> list1[i] += list2[i]
            list1[i] % 5 == 0 -> list1[i] -= list2[i]
        }
    }
    return list1
}