/**
 * Given a list of numbers 'nums' and an index 'index', this function
 * returns the intersection point between indexing tuples and number line representation.
 *
 * @param nums a list of numbers (float/integer)
 * @param index an index (integer)
 * @return The intersection point between indexing tuples and number line representation
 */
fun indexAndNumberLine(nums: List<Double>, index: Int): Double {

    nums.sorted() // Sort the list of numbers in ascending order

    // Calculate the index range in terms of the number line representation
    val minNum = nums.minOrNull() ?: 0.0
    val maxNum = nums.maxOrNull() ?: 0.0
    val rangeNum = maxNum - minNum

    // Determine the step size for each index range on the number line
    val stepSize = if (rangeNum == 0.0) {
        0.0
    } else {
        if (index == 0) {
            rangeNum / nums.size
        } else {
            (rangeNum / nums.size) / index
        }
    }

    // Calculate the value at the given index on the number line representation
    return minNum + (index * stepSize)
}
/**
 * Given a list of numbers 'nums' and an index 'index', this function
 * returns the intersection point between indexing tuples and number line representation.
 *
 * @param nums a list of numbers (float/integer)
 * @param index an index (integer)
 * @return The intersection point between indexing tuples and number line representation
 */
fun indexAndNumberLine(nums: List<Double>, index: Int): Double {
/**
 * Given a list of numbers 'nums' and an index 'index', this function
 * returns the intersection point between indexing tuples and number line representation.
 *
 * @param nums a list of numbers (float/integer)
 * @param index an index (integer)
 * @return The intersection point between indexing tuples and number line representation
 */
fun indexAndNumberLine(nums: List<Double>, index: Int): Double {

    nums.sorted() // Sort the list of numbers in ascending order

    // Calculate the index range in terms of the number line representation
    val minNum = nums.minOrNull() ?: 0.0
    val maxNum = nums.maxOrNull() ?: 0.0
    val rangeNum = maxNum - minNum

    // Determine the step size for each index range on the number line
    val stepSize = if (rangeNum == 0.0) {
        0.0
    } else {
        if (index == 0) {
            rangeNum / nums.size
        } else {
            (rangeNum / nums.size) / index
        }
    }

    // Calculate the value at the given index on the number line representation
    return minNum + (index * stepSize)
}