Last active
April 27, 2025 18:42
-
-
Save ShakibHabibi/2579aa3ada80ecf06df6e3d9bfaf1d6d to your computer and use it in GitHub Desktop.
Noak Case Study
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Doctor(var nextFree: Int, val consultTime: Int) | |
fun estimateWait(doctors: List<Doctor>, patientsAhead: Int): Int { | |
repeat(patientsAhead) { | |
val i = doctors.indices.minByOrNull { doctors[it].nextFree }!! | |
doctors[i].nextFree += doctors[i].consultTime | |
} | |
return doctors.minOf { it.nextFree } | |
} | |
fun main() { | |
val docsQ1 = listOf(Doctor(0, 3), Doctor(0, 4)) | |
println("Q1 wait = ${estimateWait(docsQ1, 10)} minutes") | |
val docsQ2 = listOf(Doctor(0, 3), Doctor(4 - 2, 4)) | |
println("Q2 wait = ${estimateWait(docsQ2, 10)} minutes") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment