Kotlin solution using extension functions
Converts the digit to string and then reduces the list. I should probably move the logic that produces the list of digits to its own function.\n\n```\nclass Sol
Converts the digit to string and then reduces the list. I should probably move the logic that produces the list of digits to its own function.\n\n```\nclass Solution {\n    fun subtractProductAndSum(n: Int): Int {\n        val productOfDigits = n.productOfDigits()\n        val productOfSums = n.sumOfDigits()\n        return productOfDigits - productOfSums\n    }\n    \n    fun Int.productOfDigits() : Int{\n        return this.toString()\n            .map { it.toString().toInt() }\n            .reduce { product, element -> product * element }\n    }\n    \n    fun Int.sumOfDigits() : Int{\n        return this.toString()\n            .map { it.toString().toInt() }\n            .reduce { sum, element -> sum + element }\n    }\n    \n}
[]