/**
 * Given a list of values and a limit, remove any elements greater than the limit
 * and any elements with characters other than alphabets or digits.
 *
 * @param data A list of values.
 * @param n The limit for element removal.
 * @return The modified list with invalid elements removed.
 */
fun removeInvalidElements(data: List<String>, n: Int): List<String> {

    // Using filter to remove elements greater than the limit and elements with characters other than alphabets or digits
    return data.filter { it.all { it.isLetterOrDigit() } && it.length <= n }
}
/**
 * Given a list of values and a limit, remove any elements greater than the limit
 * and any elements with characters other than alphabets or digits.
 *
 * @param data A list of values.
 * @param n The limit for element removal.
 * @return The modified list with invalid elements removed.
 */
fun removeInvalidElements(data: List<String>, n: Int): List<String> {
/**
 * Given a list of values and a limit, remove any elements greater than the limit
 * and any elements with characters other than alphabets or digits.
 *
 * @param data A list of values.
 * @param n The limit for element removal.
 * @return The modified list with invalid elements removed.
 */
fun removeInvalidElements(data: List<String>, n: Int): List<String> {

    // Using filter to remove elements greater than the limit and elements with characters other than alphabets or digits
    return data.filter { it.all { it.isLetterOrDigit() } && it.length <= n }
}