/**
 * This function searches for available books within a given range of indices in a library.
 * It returns a list of available books in that range.
 *
 * @param library A list of books, where each book is represented as a string.
 * @param start The starting index for the range.
 * @param end The ending index for the range.
 * @return A list of available books within the given range, or an error message if any exception occurred.
 */
fun findAvailableBooks(library: List<String>, start: Int, end: Int): List<String> {

    try {
        val availableBooks = mutableListOf<String>()
        for (index in start..end) {
            val book = library[index]
            if (!book.startsWith("Borrowed")) {
                availableBooks.add(book)
            }
        }
        return availableBooks
    } catch (e: IndexOutOfBoundsException) {
        return listOf("Error: $e")
    }
}
/**
 * This function searches for available books within a given range of indices in a library.
 * It returns a list of available books in that range.
 *
 * @param library A list of books, where each book is represented as a string.
 * @param start The starting index for the range.
 * @param end The ending index for the range.
 * @return A list of available books within the given range, or an error message if any exception occurred.
 */
fun findAvailableBooks(library: List<String>, start: Int, end: Int): List<String> {
/**
 * This function searches for available books within a given range of indices in a library.
 * It returns a list of available books in that range.
 *
 * @param library A list of books, where each book is represented as a string.
 * @param start The starting index for the range.
 * @param end The ending index for the range.
 * @return A list of available books within the given range, or an error message if any exception occurred.
 */
fun findAvailableBooks(library: List<String>, start: Int, end: Int): List<String> {

    try {
        val availableBooks = mutableListOf<String>()
        for (index in start..end) {
            val book = library[index]
            if (!book.startsWith("Borrowed")) {
                availableBooks.add(book)
            }
        }
        return availableBooks
    } catch (e: IndexOutOfBoundsException) {
        return listOf("Error: $e")
    }
}