/**
 * Given a list of patient data, a threshold value, and a flag,
 * this function filters the data based on certain conditions.
 *
 * @param patientData List of patient data
 * @param threshold Threshold value to filter the data
 * @param flag Flag indicating additional condition
 * @return Filtered data based on conditions
 *
 * The exercise requires you to complete the code to filter data
 * using nested if statements and slicing.
 */
fun sliceNestedIf(patientData: List<List<Float>>, threshold: Float, flag: Boolean): List<List<Float>> {

    val slicedData = mutableListOf<List<Float>>()

    // Iterate through each patient record in patientData
    for (record in patientData) {
        // Check if record satisfies the first condition
        if (record[0] > threshold) {
            // Check if flag is true
            if (flag) {
                // Check if record satisfies the additional condition
                if (record[1] < threshold) {
                    // Append the record to slicedData list
                    slicedData.add(record)
                }
            } else {
                // Append the record to slicedData list
                slicedData.add(record)
            }
        }
    }

    return slicedData
}
/**
 * Given a list of patient data, a threshold value, and a flag,
 * this function filters the data based on certain conditions.
 *
 * @param patientData List of patient data
 * @param threshold Threshold value to filter the data
 * @param flag Flag indicating additional condition
 * @return Filtered data based on conditions
 *
 * The exercise requires you to complete the code to filter data
 * using nested if statements and slicing.
 */
fun sliceNestedIf(patientData: List<List<Float>>, threshold: Float, flag: Boolean): List<List<Float>> {
/**
 * Given a list of patient data, a threshold value, and a flag,
 * this function filters the data based on certain conditions.
 *
 * @param patientData List of patient data
 * @param threshold Threshold value to filter the data
 * @param flag Flag indicating additional condition
 * @return Filtered data based on conditions
 *
 * The exercise requires you to complete the code to filter data
 * using nested if statements and slicing.
 */
fun sliceNestedIf(patientData: List<List<Float>>, threshold: Float, flag: Boolean): List<List<Float>> {

    val slicedData = mutableListOf<List<Float>>()

    // Iterate through each patient record in patientData
    for (record in patientData) {
        // Check if record satisfies the first condition
        if (record[0] > threshold) {
            // Check if flag is true
            if (flag) {
                // Check if record satisfies the additional condition
                if (record[1] < threshold) {
                    // Append the record to slicedData list
                    slicedData.add(record)
                }
            } else {
                // Append the record to slicedData list
                slicedData.add(record)
            }
        }
    }

    return slicedData
}