/**
 * This exercise is aimed at finding the common letters between two strings.
 * The function takes two strings as input and returns a list of the common letters found in both strings.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common letters.
 *
 * Example:
 * findCommonLetters("economics", "ireland") // ['e', 'i', 'c']
 * findCommonLetters("macro", "micro") // ['m', 'r', 'o']
 * findCommonLetters("demand", "supply") // ['d']
 * findCommonLetters("analysis", "research") // ['a', 's']
 */
fun findCommonLetters(string1: String, string2: String): List<Char> {

    val commonLetters = mutableListOf<Char>()
    for (char1 in string1) {
        if (char1 == ' ') {
            continue
        }
        for (char2 in string2) {
            if (char2 == ' ') {
                continue
            }
            if (char1 == char2 && char1 !in commonLetters) {
                commonLetters.add(char1)
            }
        }
    }
    return commonLetters
}
/**
 * This exercise is aimed at finding the common letters between two strings.
 * The function takes two strings as input and returns a list of the common letters found in both strings.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common letters.
 *
 * Example:
 * findCommonLetters("economics", "ireland") // ['e', 'i', 'c']
 * findCommonLetters("macro", "micro") // ['m', 'r', 'o']
 * findCommonLetters("demand", "supply") // ['d']
 * findCommonLetters("analysis", "research") // ['a', 's']
 */
fun findCommonLetters(string1: String, string2: String): List<Char> {
/**
 * This exercise is aimed at finding the common letters between two strings.
 * The function takes two strings as input and returns a list of the common letters found in both strings.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common letters.
 *
 * Example:
 * findCommonLetters("economics", "ireland") // ['e', 'i', 'c']
 * findCommonLetters("macro", "micro") // ['m', 'r', 'o']
 * findCommonLetters("demand", "supply") // ['d']
 * findCommonLetters("analysis", "research") // ['a', 's']
 */
fun findCommonLetters(string1: String, string2: String): List<Char> {

    val commonLetters = mutableListOf<Char>()
    for (char1 in string1) {
        if (char1 == ' ') {
            continue
        }
        for (char2 in string2) {
            if (char2 == ' ') {
                continue
            }
            if (char1 == char2 && char1 !in commonLetters) {
                commonLetters.add(char1)
            }
        }
    }
    return commonLetters
}