Sum Digits Until One
Given a list, for each element in the list, repeatedly sum the digits until it becomes a single-digit number. Then return the mode of the resulting numbers.
For example:
['1234', '24', '33'] → ['10', '6', '6'] → ['1', '6', '6']
So the result is 6.
Complete the function sumDigitsUntilOne in the editor.
sumDigitsUntilOne has the following parameter:
List: a list of strings representing numbersnumbers
Returns
int: the mode of the single-digit numbers obtained by repeatedly summing the digits
1Example 1
The process of summing the digits repeatedly until a single-digit number is obtained is as follows:
- 1234 → 1+2+3+4 = 10 → 1+0 = 1
- 24 → 2+4 = 6
- 33 → 3+3 = 6
The resulting single-digit numbers are 1, 6, and 6. The mode of these numbers is 6.