## [Solved] How to sort sum digits from the following list [closed]

Sorting list items considering unit’s place. You can try: list1 = [1236,985,150,641876,167] sorted(list1, key=lambda n: n%10) [150, 985, 1236, 641876, 167] solved How to sort sum digits from the following list [closed]

## [Solved] How to sum the digits of a number using Recursion [C]? [closed]

While @SamGrondahl is on the right track, unfortunately, if you enter a negative number it gives unexpected results. This should work properly with negative numbers: int sumdigits(int number) { int sign = number < 0 ? -1 : 1; number = sign * number; // abs the number if (number < 10) return sign * … Read more

## [Solved] How to count the number of different digits in a number? [closed]

Use sets! static int NumberOfDigits(int a) { return new HashSet<char>(Math.Abs(a).ToString()).Count; } We make a into a string and then turn the string into a set of characters. Since sets cannot contain duplicate values, the count of the set is the number of distinct digits. solved How to count the number of different digits in a … Read more