Numbers Versus Digits
Sometimes it is useful to look at numbers in two ways: as whole values and as separate digits. Write a function difference_of_sum that first finds the sum of all numbers in nums, then finds the sum of all digits inside those numbers. Return the absolute difference between these two sums.
Примеры
Ввод
[1, 15, 6, 3]Вывод
9Ввод
[1, 2, 3, 4]Вывод
0Ввод
[10]Вывод
9Нужно реализовать
def difference_of_sum(nums: list[int]) -> int:
Теги
arraymath
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inVisible tests
1
Input
[1,15,6,3]Expected
92
Input
[1,2,3,4]Expected
03
Input
[10]Expected
94
Input
[100]Expected
995
Input
[5]Expected
06
Input
[99,99]Expected
162Focus radio
Paused · SomaFM · Fluid