/**
 * This exercise aims to test your understanding of creating a dictionary and using nested ternary operators to find the intersection of two lists.
 * Your task is to complete the code by using the given lists to create a dictionary where the keys are the common elements between the two lists, and the values are their respective indices in the lists.
 * The function should return the final dictionary. Good luck!
 */
fun intersectionDictTernaryEngineer(list1: List<Int>, list2: List<Int>): Map<Int, Int> {

    // Initialize an empty dictionary
    val resultDict = mutableMapOf<Int, Int>()

    // Create a dictionary with the common elements as keys and their respective indices as values
    // Use nested ternary operators to achieve this in a concise manner
    for ((index1, value1) in list1.withIndex()) {
        for ((index2, value2) in list2.withIndex()) {
            if (value1 == value2) {
                resultDict[value1] = if (index1 < index2) index1 else index2
            }
        }
    }

    // Return the final dictionary
    return resultDict
}
/**
 * This exercise aims to test your understanding of creating a dictionary and using nested ternary operators to find the intersection of two lists.
 * Your task is to complete the code by using the given lists to create a dictionary where the keys are the common elements between the two lists, and the values are their respective indices in the lists.
 * The function should return the final dictionary. Good luck!
 */
fun intersectionDictTernaryEngineer(list1: List<Int>, list2: List<Int>): Map<Int, Int> {
/**
 * This exercise aims to test your understanding of creating a dictionary and using nested ternary operators to find the intersection of two lists.
 * Your task is to complete the code by using the given lists to create a dictionary where the keys are the common elements between the two lists, and the values are their respective indices in the lists.
 * The function should return the final dictionary. Good luck!
 */
fun intersectionDictTernaryEngineer(list1: List<Int>, list2: List<Int>): Map<Int, Int> {

    // Initialize an empty dictionary
    val resultDict = mutableMapOf<Int, Int>()

    // Create a dictionary with the common elements as keys and their respective indices as values
    // Use nested ternary operators to achieve this in a concise manner
    for ((index1, value1) in list1.withIndex()) {
        for ((index2, value2) in list2.withIndex()) {
            if (value1 == value2) {
                resultDict[value1] = if (index1 < index2) index1 else index2
            }
        }
    }

    // Return the final dictionary
    return resultDict
}