/**
 * This function takes in a list of photos and returns a string of concatenated names.
 * Each photo name should be appended to the previous name if the photo was taken by the same photographer.
 */
fun concatenatePhotos(photos: List<Map<String, String>>): String {

    if (photos.isEmpty()) {
        return ""
    }

    var photographer: String? = null
    val photographerPhotos = mutableListOf<String>()
    var concatenatedNames = ""

    for (photo in photos) {
        if (photographer == null) {
            photographer = photo["photographer"]
            photographerPhotos.add(photo["name"]!!)
        } else if (photographer == photo["photographer"]) {
            photographerPhotos.add(photo["name"]!!)
        } else {
            concatenatedNames += photographerPhotos.joinToString(" - ") + "\n"
            photographer = photo["photographer"]
            photographerPhotos.clear()
            photographerPhotos.add(photo["name"]!!)
        }
    }

    concatenatedNames += photographerPhotos.joinToString(" - ")

    return concatenatedNames
}
/**
 * This function takes in a list of photos and returns a string of concatenated names.
 * Each photo name should be appended to the previous name if the photo was taken by the same photographer.
 */
fun concatenatePhotos(photos: List<Map<String, String>>): String {
/**
 * This function takes in a list of photos and returns a string of concatenated names.
 * Each photo name should be appended to the previous name if the photo was taken by the same photographer.
 */
fun concatenatePhotos(photos: List<Map<String, String>>): String {

    if (photos.isEmpty()) {
        return ""
    }

    var photographer: String? = null
    val photographerPhotos = mutableListOf<String>()
    var concatenatedNames = ""

    for (photo in photos) {
        if (photographer == null) {
            photographer = photo["photographer"]
            photographerPhotos.add(photo["name"]!!)
        } else if (photographer == photo["photographer"]) {
            photographerPhotos.add(photo["name"]!!)
        } else {
            concatenatedNames += photographerPhotos.joinToString(" - ") + "\n"
            photographer = photo["photographer"]
            photographerPhotos.clear()
            photographerPhotos.add(photo["name"]!!)
        }
    }

    concatenatedNames += photographerPhotos.joinToString(" - ")

    return concatenatedNames
}