/**
 * Given a neighborhood represented as a grid, a list of suspects in that neighborhood, and a tracking device,
 * this function updates the tracking device with the count of suspects present in each location of the grid,
 * and returns the updated tracking device.
 *
 * @param neighborhood A 2D list representing the neighborhood grid.
 * @param suspectList A list of pairs containing the suspect names and their respective locations.
 * @param trackingDevice A 2D list representing the tracking device grid.
 * @return The updated tracking device after counting the number of suspects in each location.
 */
fun apprehendSuspects(neighborhood: List<List<Int>>, suspectList: List<Pair<String, Pair<Int, Int>>>, trackingDevice: MutableList<MutableList<Int>>): MutableList<MutableList<Int>> {

    for (i in neighborhood.indices) {
        for (j in neighborhood[0].indices) {
            var numSuspects = 0
            for (suspect in suspectList) {
                if (suspect.second == Pair(i, j)) {
                    numSuspects++
                }
            }
            trackingDevice[i][j] = numSuspects
        }
    }
    return trackingDevice
}

// Example usage
val neighborhoodGrid = listOf(
    listOf(1, 0, 0, 1),
    listOf(0, 1, 1, 0),
    listOf(1, 0, 1, 1)
)

val suspectList = listOf(
    Pair("Suspect1", Pair(0, 0)),
    Pair("Suspect2", Pair(1, 2)),
    Pair("Suspect3", Pair(2, 3))
)

val trackingDeviceGrid = MutableList(neighborhoodGrid.size) { MutableList(neighborhoodGrid[0].size) { 0 } }

val updatedTrackingDevice = apprehendSuspects(neighborhoodGrid, suspectList, trackingDeviceGrid)
/**
 * Given a neighborhood represented as a grid, a list of suspects in that neighborhood, and a tracking device,
 * this function updates the tracking device with the count of suspects present in each location of the grid,
 * and returns the updated tracking device.
 *
 * @param neighborhood A 2D list representing the neighborhood grid.
 * @param suspectList A list of pairs containing the suspect names and their respective locations.
 * @param trackingDevice A 2D list representing the tracking device grid.
 * @return The updated tracking device after counting the number of suspects in each location.
 */
fun apprehendSuspects(neighborhood: List<List<Int>>, suspectList: List<Pair<String, Pair<Int, Int>>>, trackingDevice: MutableList<MutableList<Int>>): MutableList<MutableList<Int>> {
/**
 * Given a neighborhood represented as a grid, a list of suspects in that neighborhood, and a tracking device,
 * this function updates the tracking device with the count of suspects present in each location of the grid,
 * and returns the updated tracking device.
 *
 * @param neighborhood A 2D list representing the neighborhood grid.
 * @param suspectList A list of pairs containing the suspect names and their respective locations.
 * @param trackingDevice A 2D list representing the tracking device grid.
 * @return The updated tracking device after counting the number of suspects in each location.
 */
fun apprehendSuspects(neighborhood: List<List<Int>>, suspectList: List<Pair<String, Pair<Int, Int>>>, trackingDevice: MutableList<MutableList<Int>>): MutableList<MutableList<Int>> {

    for (i in neighborhood.indices) {
        for (j in neighborhood[0].indices) {
            var numSuspects = 0
            for (suspect in suspectList) {
                if (suspect.second == Pair(i, j)) {
                    numSuspects++
                }
            }
            trackingDevice[i][j] = numSuspects
        }
    }
    return trackingDevice
}

// Example usage
val neighborhoodGrid = listOf(
    listOf(1, 0, 0, 1),
    listOf(0, 1, 1, 0),
    listOf(1, 0, 1, 1)
)

val suspectList = listOf(
    Pair("Suspect1", Pair(0, 0)),
    Pair("Suspect2", Pair(1, 2)),
    Pair("Suspect3", Pair(2, 3))
)

val trackingDeviceGrid = MutableList(neighborhoodGrid.size) { MutableList(neighborhoodGrid[0].size) { 0 } }

val updatedTrackingDevice = apprehendSuspects(neighborhoodGrid, suspectList, trackingDeviceGrid)