/**
 * Compute the intersection of two lists using the range function.
 *
 * @param rangeStart The starting point of the range.
 * @param rangeEnd The ending point of the range.
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection of list1 and list2.
 * @throws IllegalArgumentException If rangeStart or rangeEnd are not integers.
 */
fun intersectionLists(rangeStart: Int, rangeEnd: Int, list1: List<Int>, list2: List<Int>): List<Int> {

    if (rangeStart !is Int || rangeEnd !is Int) {
        throw IllegalArgumentException("rangeStart and rangeEnd must be integers.")
    }

    // Create an empty list to store the intersection
    val intersection = mutableListOf<Int>()

    // Iterate through the range
    for (i in rangeStart..rangeEnd) {
        // Check if i is present in both lists
        if (i in list1 && i in list2) {
            // Add i to the intersection list
            intersection.add(i)
        }
    }

    return intersection
}
/**
 * Compute the intersection of two lists using the range function.
 *
 * @param rangeStart The starting point of the range.
 * @param rangeEnd The ending point of the range.
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection of list1 and list2.
 * @throws IllegalArgumentException If rangeStart or rangeEnd are not integers.
 */
fun intersectionLists(rangeStart: Int, rangeEnd: Int, list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Compute the intersection of two lists using the range function.
 *
 * @param rangeStart The starting point of the range.
 * @param rangeEnd The ending point of the range.
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection of list1 and list2.
 * @throws IllegalArgumentException If rangeStart or rangeEnd are not integers.
 */
fun intersectionLists(rangeStart: Int, rangeEnd: Int, list1: List<Int>, list2: List<Int>): List<Int> {

    if (rangeStart !is Int || rangeEnd !is Int) {
        throw IllegalArgumentException("rangeStart and rangeEnd must be integers.")
    }

    // Create an empty list to store the intersection
    val intersection = mutableListOf<Int>()

    // Iterate through the range
    for (i in rangeStart..rangeEnd) {
        // Check if i is present in both lists
        if (i in list1 && i in list2) {
            // Add i to the intersection list
            intersection.add(i)
        }
    }

    return intersection
}