/**
 * This exercise aims to test your knowledge of breaking out of a loop and list slicing.
 *
 * You are given two lists, list1 and list2. Your task is to write a code that iterates through
 * both lists simultaneously using a loop. However, there is a catch. If the element in list1
 * is equal to the element in list2, the loop should break.
 *
 * Your code should then return a list containing the elements from the start of list1 up to the
 * element where the loop broke, excluding the breaking point element itself.
 *
 * For example, given the input lists [1, 2, 3, 4, 5] and [6, 7, 3, 9, 10], your code should return
 * the list [1, 2].
 */
fun breakLoop(list1: List<Int>, list2: List<Int>): List<Int> {

    val slicedList = mutableListOf<Int>()

    for ((i, j) in list1.zip(list2)) {
        if (i == j) {
            break
        } else {
            slicedList.add(i)
        }
    }

    return slicedList
}
/**
 * This exercise aims to test your knowledge of breaking out of a loop and list slicing.
 *
 * You are given two lists, list1 and list2. Your task is to write a code that iterates through
 * both lists simultaneously using a loop. However, there is a catch. If the element in list1
 * is equal to the element in list2, the loop should break.
 *
 * Your code should then return a list containing the elements from the start of list1 up to the
 * element where the loop broke, excluding the breaking point element itself.
 *
 * For example, given the input lists [1, 2, 3, 4, 5] and [6, 7, 3, 9, 10], your code should return
 * the list [1, 2].
 */
fun breakLoop(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This exercise aims to test your knowledge of breaking out of a loop and list slicing.
 *
 * You are given two lists, list1 and list2. Your task is to write a code that iterates through
 * both lists simultaneously using a loop. However, there is a catch. If the element in list1
 * is equal to the element in list2, the loop should break.
 *
 * Your code should then return a list containing the elements from the start of list1 up to the
 * element where the loop broke, excluding the breaking point element itself.
 *
 * For example, given the input lists [1, 2, 3, 4, 5] and [6, 7, 3, 9, 10], your code should return
 * the list [1, 2].
 */
fun breakLoop(list1: List<Int>, list2: List<Int>): List<Int> {

    val slicedList = mutableListOf<Int>()

    for ((i, j) in list1.zip(list2)) {
        if (i == j) {
            break
        } else {
            slicedList.add(i)
        }
    }

    return slicedList
}