/**
 * Given an article (a list of words) and a number n,
 * return a new list with the first n words from the article.
 *
 * @param article A list of words representing an article.
 * @param n The number of words to extract from the article.
 * @return A new list with the first n words from the article.
 *
 * Example:
 * article = listOf("This", "is", "a", "sample", "article")
 * getFirstNWordsFromArticle(article, 3) // Output: ["This", "is", "a"]
 */
fun getFirstNWordsFromArticle(article: List<String>, n: Int): List<String> {

    val words = mutableListOf<String>()
    for (i in 0 until n) {
        // Extract the ith word from the article using negative indexing
        val word = article[article.size - i - 1]
        words.add(word)
    }
    return words
}
/**
 * Given an article (a list of words) and a number n,
 * return a new list with the first n words from the article.
 *
 * @param article A list of words representing an article.
 * @param n The number of words to extract from the article.
 * @return A new list with the first n words from the article.
 *
 * Example:
 * article = listOf("This", "is", "a", "sample", "article")
 * getFirstNWordsFromArticle(article, 3) // Output: ["This", "is", "a"]
 */
fun getFirstNWordsFromArticle(article: List<String>, n: Int): List<String> {
/**
 * Given an article (a list of words) and a number n,
 * return a new list with the first n words from the article.
 *
 * @param article A list of words representing an article.
 * @param n The number of words to extract from the article.
 * @return A new list with the first n words from the article.
 *
 * Example:
 * article = listOf("This", "is", "a", "sample", "article")
 * getFirstNWordsFromArticle(article, 3) // Output: ["This", "is", "a"]
 */
fun getFirstNWordsFromArticle(article: List<String>, n: Int): List<String> {

    val words = mutableListOf<String>()
    for (i in 0 until n) {
        // Extract the ith word from the article using negative indexing
        val word = article[article.size - i - 1]
        words.add(word)
    }
    return words
}