Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions solutions/python/practice411.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Problem: Digit Frequency Score
# Source: https://leetcode.com/problems/digit-frequency-score
# Note:
# Status: IN PROGRESS
# Source: https://leetcode.com/problems/digit-frequency-score/
# Note: Adding each digit once per occurrence is equivalent to weighting it by frequency.
# Status: ✅ Done


class Solution(object):
def digitFrequencyScore(self, n):
"""
:type n: int
:rtype: int
"""
return
"""Return the sum of the decimal digits of n."""
return sum(int(digit) for digit in str(n))


solution = Solution()
assert solution.digitFrequencyScore(122) == 5
assert solution.digitFrequencyScore(101) == 2
if __name__ == "__main__":
solution = Solution()
assert solution.digitFrequencyScore(122) == 5
assert solution.digitFrequencyScore(101) == 2
assert solution.digitFrequencyScore(9999) == 36
Loading