/**
 * Given a nested list of car records and a list of officer badges, 
 * this function finds the badge number of an officer who witnessed a stolen car. 
 * 
 * Each car record is represented as a dictionary with keys 'car_id', 'owner', and 'witnesses'.
 * The 'witnesses' key contains a nested list of dictionaries, where each dictionary represents a witness
 * and contains keys 'name' and 'badge_number'.
 * 
 * @param carRecords A nested list of car records.
 * @param officerBadges A list of officer badges.
 * @return The badge number of an officer who witnessed a stolen car.
 */
fun findStolenCar(carRecords: List<List<Map<String, Any>>>, officerBadges: List<Int>): String {

    for (records in carRecords) {
        for (record in records) {
            val witnesses = record["witnesses"] as List<Map<String, Any>>
            for (witness in witnesses) {
                if (witness["badge_number"] in officerBadges) {
                    if ("stolen" in record["car_id"] as String) {
                        return witness["badge_number"].toString()
                    }
                }
            }
        }
    }
    return "No officer witnessed a stolen car"
}
/**
 * Given a nested list of car records and a list of officer badges, 
 * this function finds the badge number of an officer who witnessed a stolen car. 
 * 
 * Each car record is represented as a dictionary with keys 'car_id', 'owner', and 'witnesses'.
 * The 'witnesses' key contains a nested list of dictionaries, where each dictionary represents a witness
 * and contains keys 'name' and 'badge_number'.
 * 
 * @param carRecords A nested list of car records.
 * @param officerBadges A list of officer badges.
 * @return The badge number of an officer who witnessed a stolen car.
 */
fun findStolenCar(carRecords: List<List<Map<String, Any>>>, officerBadges: List<Int>): String {
/**
 * Given a nested list of car records and a list of officer badges, 
 * this function finds the badge number of an officer who witnessed a stolen car. 
 * 
 * Each car record is represented as a dictionary with keys 'car_id', 'owner', and 'witnesses'.
 * The 'witnesses' key contains a nested list of dictionaries, where each dictionary represents a witness
 * and contains keys 'name' and 'badge_number'.
 * 
 * @param carRecords A nested list of car records.
 * @param officerBadges A list of officer badges.
 * @return The badge number of an officer who witnessed a stolen car.
 */
fun findStolenCar(carRecords: List<List<Map<String, Any>>>, officerBadges: List<Int>): String {

    for (records in carRecords) {
        for (record in records) {
            val witnesses = record["witnesses"] as List<Map<String, Any>>
            for (witness in witnesses) {
                if (witness["badge_number"] in officerBadges) {
                    if ("stolen" in record["car_id"] as String) {
                        return witness["badge_number"].toString()
                    }
                }
            }
        }
    }
    return "No officer witnessed a stolen car"
}