/**
 * This function finds the common items between two sets and adds them to a list.
 *
 * @param designSet a set containing items chosen by the interior designer
 * @param otherSet a set containing other items
 *        each item is represented as a tuple in the format (category, name)
 * @param itemList a list to store the common items
 * @return updated list with the common items
 *
 * Note:
 * - If there are no common items, the function returns an empty list.
 * - The function only checks for common items in the same category.
 * - The function stops searching when it finds the first common item in each category.
 */
fun findCommonItems(designSet: Set<Pair<String, String>>, otherSet: Set<Pair<String, String>>, itemList: MutableList<String>): List<String> {

    for ((category, designItem) in designSet) {
        for ((otherCategory, otherItem) in otherSet) {
            if (category == otherCategory && designItem == otherItem) {
                itemList.add(designItem)
                break
            }
        }
    }
    return itemList
}

// Example usage
val designSet = setOf("lighting" to "chandelier", "furniture" to "sofa", "decor" to "vase")
val otherSet = setOf("lighting" to "...")
val itemList = mutableListOf<String>()
val commonItems = findCommonItems(designSet, otherSet, itemList)
/**
 * This function finds the common items between two sets and adds them to a list.
 *
 * @param designSet a set containing items chosen by the interior designer
 * @param otherSet a set containing other items
 *        each item is represented as a tuple in the format (category, name)
 * @param itemList a list to store the common items
 * @return updated list with the common items
 *
 * Note:
 * - If there are no common items, the function returns an empty list.
 * - The function only checks for common items in the same category.
 * - The function stops searching when it finds the first common item in each category.
 */
fun findCommonItems(designSet: Set<Pair<String, String>>, otherSet: Set<Pair<String, String>>, itemList: MutableList<String>): List<String> {
/**
 * This function finds the common items between two sets and adds them to a list.
 *
 * @param designSet a set containing items chosen by the interior designer
 * @param otherSet a set containing other items
 *        each item is represented as a tuple in the format (category, name)
 * @param itemList a list to store the common items
 * @return updated list with the common items
 *
 * Note:
 * - If there are no common items, the function returns an empty list.
 * - The function only checks for common items in the same category.
 * - The function stops searching when it finds the first common item in each category.
 */
fun findCommonItems(designSet: Set<Pair<String, String>>, otherSet: Set<Pair<String, String>>, itemList: MutableList<String>): List<String> {

    for ((category, designItem) in designSet) {
        for ((otherCategory, otherItem) in otherSet) {
            if (category == otherCategory && designItem == otherItem) {
                itemList.add(designItem)
                break
            }
        }
    }
    return itemList
}

// Example usage
val designSet = setOf("lighting" to "chandelier", "furniture" to "sofa", "decor" to "vase")
val otherSet = setOf("lighting" to "...")
val itemList = mutableListOf<String>()
val commonItems = findCommonItems(designSet, otherSet, itemList)