/**
 * Given a list of patients and a condition, return a list containing the names of the patients
 * who have the specified condition. Use a while loop and the OR operator to iterate through the
 * patient list.
 *
 * @param patientsList A list of patient names and their corresponding conditions.
 * @param condition The condition to filter the list of patients by.
 * @return A list of patient names who have the specified condition.
 */
fun patientsWithCondition(patientsList: List<Pair<String, String>>, condition: String): List<String> {

    val matchingPatients = mutableListOf<String>()
    var index = 0

    while (index < patientsList.size) {
        val (patientName, patientCondition) = patientsList[index]

        if (patientCondition == condition) {
            matchingPatients.add(patientName)
        }

        index++
    }

    return matchingPatients
}

// Example Usage:
val patients = listOf(Pair("John", "knee pain"), Pair("Lisa", "back pain"), Pair("Alex", "knee pain"), Pair("Sarah", "neck pain"))
val targetCondition = "knee pain"

val result = patientsWithCondition(patients, targetCondition)
/**
 * Given a list of patients and a condition, return a list containing the names of the patients
 * who have the specified condition. Use a while loop and the OR operator to iterate through the
 * patient list.
 *
 * @param patientsList A list of patient names and their corresponding conditions.
 * @param condition The condition to filter the list of patients by.
 * @return A list of patient names who have the specified condition.
 */
fun patientsWithCondition(patientsList: List<Pair<String, String>>, condition: String): List<String> {
/**
 * Given a list of patients and a condition, return a list containing the names of the patients
 * who have the specified condition. Use a while loop and the OR operator to iterate through the
 * patient list.
 *
 * @param patientsList A list of patient names and their corresponding conditions.
 * @param condition The condition to filter the list of patients by.
 * @return A list of patient names who have the specified condition.
 */
fun patientsWithCondition(patientsList: List<Pair<String, String>>, condition: String): List<String> {

    val matchingPatients = mutableListOf<String>()
    var index = 0

    while (index < patientsList.size) {
        val (patientName, patientCondition) = patientsList[index]

        if (patientCondition == condition) {
            matchingPatients.add(patientName)
        }

        index++
    }

    return matchingPatients
}

// Example Usage:
val patients = listOf(Pair("John", "knee pain"), Pair("Lisa", "back pain"), Pair("Alex", "knee pain"), Pair("Sarah", "neck pain"))
val targetCondition = "knee pain"

val result = patientsWithCondition(patients, targetCondition)