/**
 * This function takes a list of strings and a nested list as input.
 * It returns a new list containing the strings that have at least one character
 * in common with each sublist in the nested list.
 *
 * @param stringList List of strings
 * @param nestedList Nested list of characters
 * @return List of strings with characters in common with each sublist
 */
fun intersectNestedLists(stringList: List<String>, nestedList: List<List<Char>>): List<String> {

    val result = mutableListOf<String>()
    for (sublist in nestedList) {
        var commonChars = ""
        for (char in sublist) {
            if (char in stringList[0]) {
                commonChars += char
            }
        }
        for (string in stringList) {
            if (commonChars.all { it in string }) {
                result.add(string)
            }
        }
    }
    return result
}
/**
 * This function takes a list of strings and a nested list as input.
 * It returns a new list containing the strings that have at least one character
 * in common with each sublist in the nested list.
 *
 * @param stringList List of strings
 * @param nestedList Nested list of characters
 * @return List of strings with characters in common with each sublist
 */
fun intersectNestedLists(stringList: List<String>, nestedList: List<List<Char>>): List<String> {
/**
 * This function takes a list of strings and a nested list as input.
 * It returns a new list containing the strings that have at least one character
 * in common with each sublist in the nested list.
 *
 * @param stringList List of strings
 * @param nestedList Nested list of characters
 * @return List of strings with characters in common with each sublist
 */
fun intersectNestedLists(stringList: List<String>, nestedList: List<List<Char>>): List<String> {

    val result = mutableListOf<String>()
    for (sublist in nestedList) {
        var commonChars = ""
        for (char in sublist) {
            if (char in stringList[0]) {
                commonChars += char
            }
        }
        for (string in stringList) {
            if (commonChars.all { it in string }) {
                result.add(string)
            }
        }
    }
    return result
}