/**
 * This exercise requires the librarian to create a tuple of authors using the tuple() function.
 * Additionally, the librarian needs to apply conditional statements on lists to determine if an author has more than one book.
 *
 * @param list_of_authors A list of author names.
 * @param list_of_books A list of books written by the authors.
 * @return A tuple of authors and their respective books (if they have more than one book).
 *
 * Note:
 * - For authors with multiple books, only their name and books should appear in the tuple.
 * - Authors with a single book should not appear in the tuple.
 */
fun createAuthorTuple(listOfAuthors: List<String>, listOfBooks: List<String>): List<Pair<String, List<String>>> {

    val authorBookMap = mutableMapOf<String, MutableList<String>>()

    for ((author, book) in listOfAuthors.zip(listOfBooks)) {
        if (author in authorBookMap) {
            authorBookMap[author]!!.add(book)
        } else {
            authorBookMap[author] = mutableListOf(book)
        }
    }

    return authorBookMap.filterValues { it.size > 1 }.map { it.key to it.value }.toList()
}
/**
 * This exercise requires the librarian to create a tuple of authors using the tuple() function.
 * Additionally, the librarian needs to apply conditional statements on lists to determine if an author has more than one book.
 *
 * @param list_of_authors A list of author names.
 * @param list_of_books A list of books written by the authors.
 * @return A tuple of authors and their respective books (if they have more than one book).
 *
 * Note:
 * - For authors with multiple books, only their name and books should appear in the tuple.
 * - Authors with a single book should not appear in the tuple.
 */
fun createAuthorTuple(listOfAuthors: List<String>, listOfBooks: List<String>): List<Pair<String, List<String>>> {
/**
 * This exercise requires the librarian to create a tuple of authors using the tuple() function.
 * Additionally, the librarian needs to apply conditional statements on lists to determine if an author has more than one book.
 *
 * @param list_of_authors A list of author names.
 * @param list_of_books A list of books written by the authors.
 * @return A tuple of authors and their respective books (if they have more than one book).
 *
 * Note:
 * - For authors with multiple books, only their name and books should appear in the tuple.
 * - Authors with a single book should not appear in the tuple.
 */
fun createAuthorTuple(listOfAuthors: List<String>, listOfBooks: List<String>): List<Pair<String, List<String>>> {

    val authorBookMap = mutableMapOf<String, MutableList<String>>()

    for ((author, book) in listOfAuthors.zip(listOfBooks)) {
        if (author in authorBookMap) {
            authorBookMap[author]!!.add(book)
        } else {
            authorBookMap[author] = mutableListOf(book)
        }
    }

    return authorBookMap.filterValues { it.size > 1 }.map { it.key to it.value }.toList()
}