/**
 * Given a list of available colors and a map of user preferences,
 * this function returns a list of common colors between the two.
 *
 * @param availableColors A list of available colors in RGB format.
 * @param userPreferences A map with color preferences as keys
 *                        and their importance as values.
 * @return A list of colors that are both available and preferred.
 */
fun findCommonColors(availableColors: List<String>, userPreferences: Map<String, Int>): List<String> {

    // Initialize an empty list to store common colors
    val commonColors = mutableListOf<String>()

    // Iterate over each available color
    for (color in availableColors) {
        // Check if the current color is preferred by the user
        if (userPreferences.containsKey(color)) {
            // Add the color to the commonColors list
            commonColors.add(color)
        }
    }

    // Return the list of common colors
    return commonColors
}

// Example usage
val availableColors = listOf("#FF0000", "#00FF00", "#0000FF", "#FFFF00")
val userPreferences = mapOf("#FF0000" to 5, "#00FFFF" to 3, "#FFFF00" to 2, "#FF00FF" to 1)

val commonColors = findCommonColors(availableColors, userPreferences)
/**
 * Given a list of available colors and a map of user preferences,
 * this function returns a list of common colors between the two.
 *
 * @param availableColors A list of available colors in RGB format.
 * @param userPreferences A map with color preferences as keys
 *                        and their importance as values.
 * @return A list of colors that are both available and preferred.
 */
fun findCommonColors(availableColors: List<String>, userPreferences: Map<String, Int>): List<String> {
/**
 * Given a list of available colors and a map of user preferences,
 * this function returns a list of common colors between the two.
 *
 * @param availableColors A list of available colors in RGB format.
 * @param userPreferences A map with color preferences as keys
 *                        and their importance as values.
 * @return A list of colors that are both available and preferred.
 */
fun findCommonColors(availableColors: List<String>, userPreferences: Map<String, Int>): List<String> {

    // Initialize an empty list to store common colors
    val commonColors = mutableListOf<String>()

    // Iterate over each available color
    for (color in availableColors) {
        // Check if the current color is preferred by the user
        if (userPreferences.containsKey(color)) {
            // Add the color to the commonColors list
            commonColors.add(color)
        }
    }

    // Return the list of common colors
    return commonColors
}

// Example usage
val availableColors = listOf("#FF0000", "#00FF00", "#0000FF", "#FFFF00")
val userPreferences = mapOf("#FF0000" to 5, "#00FFFF" to 3, "#FFFF00" to 2, "#FF00FF" to 1)

val commonColors = findCommonColors(availableColors, userPreferences)