Skip to content

Instantly share code, notes, and snippets.

@ShakibHabibi
Last active April 27, 2025 18:42
Show Gist options
  • Save ShakibHabibi/2579aa3ada80ecf06df6e3d9bfaf1d6d to your computer and use it in GitHub Desktop.
Save ShakibHabibi/2579aa3ada80ecf06df6e3d9bfaf1d6d to your computer and use it in GitHub Desktop.
Noak Case Study
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