/**
 * This function takes a library map and a query as input,
 * and returns a list of books that match the query.
 *
 * @param library A map representing the library where the keys are book titles
 *                and the values are sets of authors.
 * @param query A string representing the user's search query.
 * @return A list of books that match the query.
 */
fun searchBooks(library: Map<String, Set<String>>, query: String): List<String> {

    val matchingBooks = mutableListOf<String>()

    // Iterate over each book in the library
    for ((title, authors) in library) {
        // Check if the query matches the book title or any of the authors
        if (query.toLowerCase() in title.toLowerCase() || authors.any { query.toLowerCase() in it.toLowerCase() }) {
            matchingBooks.add(title)
        }
    }

    return matchingBooks
}
/**
 * This function takes a library map and a query as input,
 * and returns a list of books that match the query.
 *
 * @param library A map representing the library where the keys are book titles
 *                and the values are sets of authors.
 * @param query A string representing the user's search query.
 * @return A list of books that match the query.
 */
fun searchBooks(library: Map<String, Set<String>>, query: String): List<String> {
/**
 * This function takes a library map and a query as input,
 * and returns a list of books that match the query.
 *
 * @param library A map representing the library where the keys are book titles
 *                and the values are sets of authors.
 * @param query A string representing the user's search query.
 * @return A list of books that match the query.
 */
fun searchBooks(library: Map<String, Set<String>>, query: String): List<String> {

    val matchingBooks = mutableListOf<String>()

    // Iterate over each book in the library
    for ((title, authors) in library) {
        // Check if the query matches the book title or any of the authors
        if (query.toLowerCase() in title.toLowerCase() || authors.any { query.toLowerCase() in it.toLowerCase() }) {
            matchingBooks.add(title)
        }
    }

    return matchingBooks
}