/**
 * Given two dictionaries representing the tool collections of two carpenters,
 * count the number of common tools they both have.
 *
 * @param carpenter1 The tool collection of the first carpenter.
 * @param carpenter2 The tool collection of the second carpenter.
 * @return The number of common tools between the two carpenters.
 *
 * Example:
 * countCommonTools(mapOf("hammer" to 2, "saw" to 1, "drill" to 1), mapOf("screwdriver" to 3, "wrench" to 2, "saw" to 1, "hammer" to 2))
 * Returns:
 * 2
 */
fun countCommonTools(carpenter1: Map<String, Int>, carpenter2: Map<String, Int>): Int {

    var commonTools = 0

    // Loop through the tools of the first carpenter
    for ((tool1, _) in carpenter1) {
        // Loop through the tools of the second carpenter
        for ((tool2, _) in carpenter2) {
            // Check if the tool is available in both carpenters' collections
            if (tool1 == tool2) {
                commonTools++
            }
        }
    }

    return commonTools
}
/**
 * Given two dictionaries representing the tool collections of two carpenters,
 * count the number of common tools they both have.
 *
 * @param carpenter1 The tool collection of the first carpenter.
 * @param carpenter2 The tool collection of the second carpenter.
 * @return The number of common tools between the two carpenters.
 *
 * Example:
 * countCommonTools(mapOf("hammer" to 2, "saw" to 1, "drill" to 1), mapOf("screwdriver" to 3, "wrench" to 2, "saw" to 1, "hammer" to 2))
 * Returns:
 * 2
 */
fun countCommonTools(carpenter1: Map<String, Int>, carpenter2: Map<String, Int>): Int {
/**
 * Given two dictionaries representing the tool collections of two carpenters,
 * count the number of common tools they both have.
 *
 * @param carpenter1 The tool collection of the first carpenter.
 * @param carpenter2 The tool collection of the second carpenter.
 * @return The number of common tools between the two carpenters.
 *
 * Example:
 * countCommonTools(mapOf("hammer" to 2, "saw" to 1, "drill" to 1), mapOf("screwdriver" to 3, "wrench" to 2, "saw" to 1, "hammer" to 2))
 * Returns:
 * 2
 */
fun countCommonTools(carpenter1: Map<String, Int>, carpenter2: Map<String, Int>): Int {

    var commonTools = 0

    // Loop through the tools of the first carpenter
    for ((tool1, _) in carpenter1) {
        // Loop through the tools of the second carpenter
        for ((tool2, _) in carpenter2) {
            // Check if the tool is available in both carpenters' collections
            if (tool1 == tool2) {
                commonTools++
            }
        }
    }

    return commonTools
}