/**
 * Given a list of books, bookTitle, and newStatus, this function modifies the availability status of a book in the list.
 *
 * @param books A list of books, where each book is represented as a string.
 * @param bookTitle The title of the book to modify.
 * @param newStatus The new availability status for the book.
 * @return The modified list of books with the updated availability status.
 */
fun modifyBooksAvailability(books: MutableList<String>, bookTitle: String, newStatus: String): MutableList<String> {

    var index = 0
    while (index < books.size) {
        if (books[index] == bookTitle) {
            books[index] = "${books[index]} - $newStatus"
        } else if (books[index].startsWith("$bookTitle -")) {
            books[index] = "${books[index].substring(0, bookTitle.length + 3)} $newStatus"
        }
        index++
    }
    return books
}
/**
 * Given a list of books, bookTitle, and newStatus, this function modifies the availability status of a book in the list.
 *
 * @param books A list of books, where each book is represented as a string.
 * @param bookTitle The title of the book to modify.
 * @param newStatus The new availability status for the book.
 * @return The modified list of books with the updated availability status.
 */
fun modifyBooksAvailability(books: MutableList<String>, bookTitle: String, newStatus: String): MutableList<String> {
/**
 * Given a list of books, bookTitle, and newStatus, this function modifies the availability status of a book in the list.
 *
 * @param books A list of books, where each book is represented as a string.
 * @param bookTitle The title of the book to modify.
 * @param newStatus The new availability status for the book.
 * @return The modified list of books with the updated availability status.
 */
fun modifyBooksAvailability(books: MutableList<String>, bookTitle: String, newStatus: String): MutableList<String> {

    var index = 0
    while (index < books.size) {
        if (books[index] == bookTitle) {
            books[index] = "${books[index]} - $newStatus"
        } else if (books[index].startsWith("$bookTitle -")) {
            books[index] = "${books[index].substring(0, bookTitle.length + 3)} $newStatus"
        }
        index++
    }
    return books
}