/**
 * This function takes a list of books and the number of students. It divides the books equally among the students and returns the remaining books.
 *
 * @param books A list of books.
 * @param numStudents An integer representing the number of students.
 * @return A list of books remaining after dividing equally among the students.
 */
fun divideBooks(books: List<String>, numStudents: Int): List<String> {

    val bookCount = books.size
    val booksPerStudent = bookCount / numStudents
    val remainder = bookCount % numStudents

    val remainingBooks = mutableListOf<String>()

    for (i in 0 until numStudents) {
        val startIndex = i * booksPerStudent
        val endIndex = startIndex + booksPerStudent

        val studentBooks = books.subList(startIndex, endIndex)

        // TODO: Assign equal number of books to each student
        // Hint: Use division assignment operator to update studentBooks with booksPerStudent divided by 2

        // TODO: Calculate the remaining books
        // Uncomment and complete the line below
        // remainingBooks.addAll(books.subList(endIndex, endIndex + remainder))

        // TODO: Print the books assigned to each student
        // Uncomment and complete the line below
        // println("Student ${i + 1} books: $studentBooks")
    }

    return remainingBooks
}
/**
 * This function takes a list of books and the number of students. It divides the books equally among the students and returns the remaining books.
 *
 * @param books A list of books.
 * @param numStudents An integer representing the number of students.
 * @return A list of books remaining after dividing equally among the students.
 */
fun divideBooks(books: List<String>, numStudents: Int): List<String> {
/**
 * This function takes a list of books and the number of students. It divides the books equally among the students and returns the remaining books.
 *
 * @param books A list of books.
 * @param numStudents An integer representing the number of students.
 * @return A list of books remaining after dividing equally among the students.
 */
fun divideBooks(books: List<String>, numStudents: Int): List<String> {

    val bookCount = books.size
    val booksPerStudent = bookCount / numStudents
    val remainder = bookCount % numStudents

    val remainingBooks = mutableListOf<String>()

    for (i in 0 until numStudents) {
        val startIndex = i * booksPerStudent
        val endIndex = startIndex + booksPerStudent

        val studentBooks = books.subList(startIndex, endIndex)

        // TODO: Assign equal number of books to each student
        // Hint: Use division assignment operator to update studentBooks with booksPerStudent divided by 2

        // TODO: Calculate the remaining books
        // Uncomment and complete the line below
        // remainingBooks.addAll(books.subList(endIndex, endIndex + remainder))

        // TODO: Print the books assigned to each student
        // Uncomment and complete the line below
        // println("Student ${i + 1} books: $studentBooks")
    }

    return remainingBooks
}