/**
 * Given a list of numbers and two indices, the function returns the number at the intersection
 * of the two indices. It checks for the index validity and if the number is positive,
 * and returns null otherwise.
 *
 * @param numbers A list of numbers
 * @param index1 The first index
 * @param index2 The second index
 * @return The number at the intersection of the indices or null if invalid indices or negative number
 */
fun indexingNestedIf(numbers: List<Int>, index1: Int, index2: Int): Int? {

    if (index1 < 0 || index2 < 0) {  // Check if indices are negative
        return null
    }

    if (index1 >= numbers.size || index2 >= numbers.size) {  // Check if indices are out of bounds
        return null
    }

    var number = numbers[index1]

    if (number >= 0) {  // Check if the number at index1 is positive
        if (index1 > index2) {  // Check if index1 is greater than index2
            number = numbers[index2]
            if (number >= 0) {  // Check if the number at index2 is positive
                return number
            }
        }
    }

    return null
}
/**
 * Given a list of numbers and two indices, the function returns the number at the intersection
 * of the two indices. It checks for the index validity and if the number is positive,
 * and returns null otherwise.
 *
 * @param numbers A list of numbers
 * @param index1 The first index
 * @param index2 The second index
 * @return The number at the intersection of the indices or null if invalid indices or negative number
 */
fun indexingNestedIf(numbers: List<Int>, index1: Int, index2: Int): Int? {
/**
 * Given a list of numbers and two indices, the function returns the number at the intersection
 * of the two indices. It checks for the index validity and if the number is positive,
 * and returns null otherwise.
 *
 * @param numbers A list of numbers
 * @param index1 The first index
 * @param index2 The second index
 * @return The number at the intersection of the indices or null if invalid indices or negative number
 */
fun indexingNestedIf(numbers: List<Int>, index1: Int, index2: Int): Int? {

    if (index1 < 0 || index2 < 0) {  // Check if indices are negative
        return null
    }

    if (index1 >= numbers.size || index2 >= numbers.size) {  // Check if indices are out of bounds
        return null
    }

    var number = numbers[index1]

    if (number >= 0) {  // Check if the number at index1 is positive
        if (index1 > index2) {  // Check if index1 is greater than index2
            number = numbers[index2]
            if (number >= 0) {  // Check if the number at index2 is positive
                return number
            }
        }
    }

    return null
}