/**
 * This function assigns patients to nurses based on certain criteria.
 *
 * @param nurses a list of nurse names
 * @param patients a nested list of patient names, each sublist represents patients assigned to a specific nurse
 * @return a nested list where each sublist now represents a nurse with their assigned patients
 */
fun assignPatients(nurses: List<String>, patients: List<List<String>>): List<List<String>> {

    val assignedPatients = mutableListOf<List<String>>()

    for (nurse in nurses) {
        assignedPatients.add(listOf(nurse)) // Initialize each sublist with a nurse's name
    }

    for (sublist in patients) {
        for (patient in sublist) {
            for (i in assignedPatients.indices) {
                // Assign patients to nurses based on certain criteria/conditions
                if (assignedPatients[i].size < 3) { // Nurses can handle up to 3 patients
                    assignedPatients[i] = assignedPatients[i] + patient
                    break
                }
            }
        }
    }

    return assignedPatients
}

// Example usage
val nurseNames = listOf("Nurse A", "Nurse B", "Nurse C")
val patientList = listOf(listOf("Patient 1", "Patient 2"), listOf("Patient 3", "Patient 4"), listOf("Patient 5", "Patient 6"))
val assignedPatients = assignPatients(nurseNames, patientList)
/**
 * This function assigns patients to nurses based on certain criteria.
 *
 * @param nurses a list of nurse names
 * @param patients a nested list of patient names, each sublist represents patients assigned to a specific nurse
 * @return a nested list where each sublist now represents a nurse with their assigned patients
 */
fun assignPatients(nurses: List<String>, patients: List<List<String>>): List<List<String>> {
/**
 * This function assigns patients to nurses based on certain criteria.
 *
 * @param nurses a list of nurse names
 * @param patients a nested list of patient names, each sublist represents patients assigned to a specific nurse
 * @return a nested list where each sublist now represents a nurse with their assigned patients
 */
fun assignPatients(nurses: List<String>, patients: List<List<String>>): List<List<String>> {

    val assignedPatients = mutableListOf<List<String>>()

    for (nurse in nurses) {
        assignedPatients.add(listOf(nurse)) // Initialize each sublist with a nurse's name
    }

    for (sublist in patients) {
        for (patient in sublist) {
            for (i in assignedPatients.indices) {
                // Assign patients to nurses based on certain criteria/conditions
                if (assignedPatients[i].size < 3) { // Nurses can handle up to 3 patients
                    assignedPatients[i] = assignedPatients[i] + patient
                    break
                }
            }
        }
    }

    return assignedPatients
}

// Example usage
val nurseNames = listOf("Nurse A", "Nurse B", "Nurse C")
val patientList = listOf(listOf("Patient 1", "Patient 2"), listOf("Patient 3", "Patient 4"), listOf("Patient 5", "Patient 6"))
val assignedPatients = assignPatients(nurseNames, patientList)