/**
 * This exercise aims to test your understanding of identity comparison and not equal operators.
 *
 * Write a function that takes two carpenters as input and returns a list of jobs they both have in common.
 * Each carpenter is represented as a dictionary with the 'name' key storing their name and the 'jobs' key storing a list of jobs they can do.
 *
 * @param carpenter1 Dictionary representing the first carpenter.
 * @param carpenter2 Dictionary representing the second carpenter.
 * @return A list of jobs both carpenters can do.
 */
fun carpenterJobs(carpenter1: Map<String, Any>, carpenter2: Map<String, Any>): List<String> {

    // Ensure carpenter1 and carpenter2 are dictionaries
    if (carpenter1 !is Map<*, *> || carpenter2 !is Map<*, *>) {
        return listOf("Error: Both carpenters should be in dictionary form!")
    }

    // Ensure the dictionary contains 'name' and 'jobs' keys
    if (!carpenter1.containsKey("name") || !carpenter2.containsKey("name") ||
        !carpenter1.containsKey("jobs") || !carpenter2.containsKey("jobs")
    ) {
        return listOf("Error: Both carpenters should have 'name' and 'jobs' keys!")
    }

    val jobs1 = carpenter1["jobs"] as? List<String> ?: emptyList()
    val jobs2 = carpenter2["jobs"] as? List<String> ?: emptyList()

    return jobs1.intersect(jobs2).toList()
}
/**
 * This exercise aims to test your understanding of identity comparison and not equal operators.
 *
 * Write a function that takes two carpenters as input and returns a list of jobs they both have in common.
 * Each carpenter is represented as a dictionary with the 'name' key storing their name and the 'jobs' key storing a list of jobs they can do.
 *
 * @param carpenter1 Dictionary representing the first carpenter.
 * @param carpenter2 Dictionary representing the second carpenter.
 * @return A list of jobs both carpenters can do.
 */
fun carpenterJobs(carpenter1: Map<String, Any>, carpenter2: Map<String, Any>): List<String> {
/**
 * This exercise aims to test your understanding of identity comparison and not equal operators.
 *
 * Write a function that takes two carpenters as input and returns a list of jobs they both have in common.
 * Each carpenter is represented as a dictionary with the 'name' key storing their name and the 'jobs' key storing a list of jobs they can do.
 *
 * @param carpenter1 Dictionary representing the first carpenter.
 * @param carpenter2 Dictionary representing the second carpenter.
 * @return A list of jobs both carpenters can do.
 */
fun carpenterJobs(carpenter1: Map<String, Any>, carpenter2: Map<String, Any>): List<String> {

    // Ensure carpenter1 and carpenter2 are dictionaries
    if (carpenter1 !is Map<*, *> || carpenter2 !is Map<*, *>) {
        return listOf("Error: Both carpenters should be in dictionary form!")
    }

    // Ensure the dictionary contains 'name' and 'jobs' keys
    if (!carpenter1.containsKey("name") || !carpenter2.containsKey("name") ||
        !carpenter1.containsKey("jobs") || !carpenter2.containsKey("jobs")
    ) {
        return listOf("Error: Both carpenters should have 'name' and 'jobs' keys!")
    }

    val jobs1 = carpenter1["jobs"] as? List<String> ?: emptyList()
    val jobs2 = carpenter2["jobs"] as? List<String> ?: emptyList()

    return jobs1.intersect(jobs2).toList()
}