/**
 * Given a library, this function returns a list of available books.
 * Each book is represented as a dictionary with the following keys:
 * - 'title': the title of the book (string)
 * - 'author': the author of the book (string)
 * - 'availability': True if the book is available, False otherwise (boolean)
 *
 * You need to implement the missing part of the code to find the available books.
 * Use nested loops and short-circuiting to make the implementation efficient.
 *
 * @param library a list of dictionaries representing the books in the library
 * @return a list of dictionaries containing the available books
 */
fun findAvailableBooks(library: List<Map<String, Any>>): List<Map<String, Any>> {

    val availableBooks = mutableListOf<Map<String, Any>>()

    // Outer loop to iterate through each book in the library
    for (book in library) {
        // Inner loop to iterate through each key in the book dictionary
        var isAvailable = true
        for ((key, value) in book) {
            // Short-circuiting: if the 'availability' key is False, skip to the next book
            if (key == "availability" && value == false) {
                isAvailable = false
                break
            }
        }
        // If the inner loop completes without breaking, the book is available
        if (isAvailable) {
            availableBooks.add(book)
        }
    }

    return availableBooks
}
/**
 * Given a library, this function returns a list of available books.
 * Each book is represented as a dictionary with the following keys:
 * - 'title': the title of the book (string)
 * - 'author': the author of the book (string)
 * - 'availability': True if the book is available, False otherwise (boolean)
 *
 * You need to implement the missing part of the code to find the available books.
 * Use nested loops and short-circuiting to make the implementation efficient.
 *
 * @param library a list of dictionaries representing the books in the library
 * @return a list of dictionaries containing the available books
 */
fun findAvailableBooks(library: List<Map<String, Any>>): List<Map<String, Any>> {
/**
 * Given a library, this function returns a list of available books.
 * Each book is represented as a dictionary with the following keys:
 * - 'title': the title of the book (string)
 * - 'author': the author of the book (string)
 * - 'availability': True if the book is available, False otherwise (boolean)
 *
 * You need to implement the missing part of the code to find the available books.
 * Use nested loops and short-circuiting to make the implementation efficient.
 *
 * @param library a list of dictionaries representing the books in the library
 * @return a list of dictionaries containing the available books
 */
fun findAvailableBooks(library: List<Map<String, Any>>): List<Map<String, Any>> {

    val availableBooks = mutableListOf<Map<String, Any>>()

    // Outer loop to iterate through each book in the library
    for (book in library) {
        // Inner loop to iterate through each key in the book dictionary
        var isAvailable = true
        for ((key, value) in book) {
            // Short-circuiting: if the 'availability' key is False, skip to the next book
            if (key == "availability" && value == false) {
                isAvailable = false
                break
            }
        }
        // If the inner loop completes without breaking, the book is available
        if (isAvailable) {
            availableBooks.add(book)
        }
    }

    return availableBooks
}