/**
 * This function takes a library and a search term as input and returns a sublist
 * of books whose titles contain the search term using list slicing.
 *
 * @param library A list of books in the library.
 * @param searchTerm The search term used to filter the books.
 * @return A sublist of books whose titles contain the search term.
 */
fun searchBooks(library: List<List<String>>, searchTerm: String): List<List<String>> {

    // Initialize an empty list to store the matching books
    val matchingBooks = mutableListOf<List<String>>()

    // Iterate over each book in the library
    var mutableLibrary = library.toMutableList()
    while (mutableLibrary.isNotEmpty()) {
        // Retrieve the title of the first book in the library using list slicing
        val title = mutableLibrary[0][0]

        // Check if the search term is present in the book title
        if (title.contains(searchTerm)) {
            // Append the book to the matchingBooks list
            matchingBooks.add(mutableLibrary[0])
        }

        // Remove the first book from the library using list slicing
        mutableLibrary = mutableLibrary.drop(1).toMutableList()
    }

    // Return the sublist of matching books
    return matchingBooks
}
/**
 * This function takes a library and a search term as input and returns a sublist
 * of books whose titles contain the search term using list slicing.
 *
 * @param library A list of books in the library.
 * @param searchTerm The search term used to filter the books.
 * @return A sublist of books whose titles contain the search term.
 */
fun searchBooks(library: List<List<String>>, searchTerm: String): List<List<String>> {
/**
 * This function takes a library and a search term as input and returns a sublist
 * of books whose titles contain the search term using list slicing.
 *
 * @param library A list of books in the library.
 * @param searchTerm The search term used to filter the books.
 * @return A sublist of books whose titles contain the search term.
 */
fun searchBooks(library: List<List<String>>, searchTerm: String): List<List<String>> {

    // Initialize an empty list to store the matching books
    val matchingBooks = mutableListOf<List<String>>()

    // Iterate over each book in the library
    var mutableLibrary = library.toMutableList()
    while (mutableLibrary.isNotEmpty()) {
        // Retrieve the title of the first book in the library using list slicing
        val title = mutableLibrary[0][0]

        // Check if the search term is present in the book title
        if (title.contains(searchTerm)) {
            // Append the book to the matchingBooks list
            matchingBooks.add(mutableLibrary[0])
        }

        // Remove the first book from the library using list slicing
        mutableLibrary = mutableLibrary.drop(1).toMutableList()
    }

    // Return the sublist of matching books
    return matchingBooks
}