/**
 * Given a list of integers 'nums' and an integer 'threshold', this function returns the sum of all
 * the digits of the numbers in the list that are below the given threshold.
 *
 * @param nums A list of integers.
 * @param threshold An integer indicating the upper threshold for selecting numbers.
 * @return An integer representing the sum of all the digits of the numbers in 'nums' that are below 'threshold'.
 */
fun sumDigitsBelowThreshold(nums: List<Int>, threshold: Int): Int {

    var digitSum = 0

    for (num in nums) {
        if (num < threshold) {
            num.toString().forEach { digit ->
                digitSum += digit.toString().toInt()  // Sum the digits
            }
        }
    }

    return digitSum
}
/**
 * Given a list of integers 'nums' and an integer 'threshold', this function returns the sum of all
 * the digits of the numbers in the list that are below the given threshold.
 *
 * @param nums A list of integers.
 * @param threshold An integer indicating the upper threshold for selecting numbers.
 * @return An integer representing the sum of all the digits of the numbers in 'nums' that are below 'threshold'.
 */
fun sumDigitsBelowThreshold(nums: List<Int>, threshold: Int): Int {
/**
 * Given a list of integers 'nums' and an integer 'threshold', this function returns the sum of all
 * the digits of the numbers in the list that are below the given threshold.
 *
 * @param nums A list of integers.
 * @param threshold An integer indicating the upper threshold for selecting numbers.
 * @return An integer representing the sum of all the digits of the numbers in 'nums' that are below 'threshold'.
 */
fun sumDigitsBelowThreshold(nums: List<Int>, threshold: Int): Int {

    var digitSum = 0

    for (num in nums) {
        if (num < threshold) {
            num.toString().forEach { digit ->
                digitSum += digit.toString().toInt()  // Sum the digits
            }
        }
    }

    return digitSum
}