/**
 * This exercise aims to test your understanding of booleans and for loops with strings.
 *
 * Given two strings, your task is to write a function that finds and returns a list of all the
 * characters that are common between both strings. The order of the characters in the returned
 * list should match their order of appearance in the first string.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters between string1 and string2.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    
    for (char1 in string1) {
        for (char2 in string2) {
            if (char1 == char2) {
                commonChars.add(char1)
            }
        }
    }
    
    return commonChars
}
/**
 * This exercise aims to test your understanding of booleans and for loops with strings.
 *
 * Given two strings, your task is to write a function that finds and returns a list of all the
 * characters that are common between both strings. The order of the characters in the returned
 * list should match their order of appearance in the first string.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters between string1 and string2.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {
/**
 * This exercise aims to test your understanding of booleans and for loops with strings.
 *
 * Given two strings, your task is to write a function that finds and returns a list of all the
 * characters that are common between both strings. The order of the characters in the returned
 * list should match their order of appearance in the first string.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters between string1 and string2.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    
    for (char1 in string1) {
        for (char2 in string2) {
            if (char1 == char2) {
                commonChars.add(char1)
            }
        }
    }
    
    return commonChars
}