/**
 * Given a list of historical events, a start year, an end year and a keyword,
 * return a list of events that occurred within the specified time range
 * and contain the keyword.
 *
 * @param events A list of historical events.
 * @param start The start year.
 * @param end The end year.
 * @param keyword The keyword to filter events.
 * @return A list of filtered events.
 */
fun filterHistoryEvents(events: List<String>, start: Int, end: Int, keyword: String): List<String> {

    val filteredEvents = mutableListOf<String>()
    for (event in events) {
        val eventYear = event.split(',')[0].toInt()
        val eventDescription = event.split(',')[1]
        
        if (start <= eventYear && eventYear <= end && keyword in eventDescription) {
            filteredEvents.add(event)
        }
    }
    return filteredEvents
}

// Example usage
val events = listOf(
    "1754,The French and Indian War begins",
    "1776,United States Declaration of Independence",
    "1789,French Revolution",
    "1861,American Civil War begins",
    "1917,Russian Revolution",
    "1945,End of World War II"
)

val startYear = 1750
val endYear = 1900
/**
 * Given a list of historical events, a start year, an end year and a keyword,
 * return a list of events that occurred within the specified time range
 * and contain the keyword.
 *
 * @param events A list of historical events.
 * @param start The start year.
 * @param end The end year.
 * @param keyword The keyword to filter events.
 * @return A list of filtered events.
 */
fun filterHistoryEvents(events: List<String>, start: Int, end: Int, keyword: String): List<String> {
/**
 * Given a list of historical events, a start year, an end year and a keyword,
 * return a list of events that occurred within the specified time range
 * and contain the keyword.
 *
 * @param events A list of historical events.
 * @param start The start year.
 * @param end The end year.
 * @param keyword The keyword to filter events.
 * @return A list of filtered events.
 */
fun filterHistoryEvents(events: List<String>, start: Int, end: Int, keyword: String): List<String> {

    val filteredEvents = mutableListOf<String>()
    for (event in events) {
        val eventYear = event.split(',')[0].toInt()
        val eventDescription = event.split(',')[1]
        
        if (start <= eventYear && eventYear <= end && keyword in eventDescription) {
            filteredEvents.add(event)
        }
    }
    return filteredEvents
}

// Example usage
val events = listOf(
    "1754,The French and Indian War begins",
    "1776,United States Declaration of Independence",
    "1789,French Revolution",
    "1861,American Civil War begins",
    "1917,Russian Revolution",
    "1945,End of World War II"
)

val startYear = 1750
val endYear = 1900