/**
 * You are a firefighter responding to a building fire. There are multiple entrances to the building, represented by a list.
 * Your task is to find the index of the entrance which is closest to the fire and safe to enter.
 *
 * Given a list 'distances' containing distances of each entrance from the fire, write a function that returns the index of the closest entrance.
 *
 * @param distances List<Int> containing distances of each entrance from the fire.
 * @return Int Index of the closest entrance.
 */
fun findEntrance(distances: List<Int>): Int {

    var closestIndex = 0
    var minDistance = Int.MAX_VALUE

    for ((index, distance) in distances.withIndex()) {
        if (distance < minDistance) {
            minDistance = distance
            closestIndex = index
        }
    }

    return closestIndex
}
/**
 * You are a firefighter responding to a building fire. There are multiple entrances to the building, represented by a list.
 * Your task is to find the index of the entrance which is closest to the fire and safe to enter.
 *
 * Given a list 'distances' containing distances of each entrance from the fire, write a function that returns the index of the closest entrance.
 *
 * @param distances List<Int> containing distances of each entrance from the fire.
 * @return Int Index of the closest entrance.
 */
fun findEntrance(distances: List<Int>): Int {
/**
 * You are a firefighter responding to a building fire. There are multiple entrances to the building, represented by a list.
 * Your task is to find the index of the entrance which is closest to the fire and safe to enter.
 *
 * Given a list 'distances' containing distances of each entrance from the fire, write a function that returns the index of the closest entrance.
 *
 * @param distances List<Int> containing distances of each entrance from the fire.
 * @return Int Index of the closest entrance.
 */
fun findEntrance(distances: List<Int>): Int {

    var closestIndex = 0
    var minDistance = Int.MAX_VALUE

    for ((index, distance) in distances.withIndex()) {
        if (distance < minDistance) {
            minDistance = distance
            closestIndex = index
        }
    }

    return closestIndex
}