Skip to content

Commit 7caba04

Browse files
Chris WuChris Wu
Chris Wu
authored and
Chris Wu
committed
no message
1 parent 46e715f commit 7caba04

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Leetcode Python Solution
22
1. This is my Python Solution on leetcode `@christopherwu0529`.
33

4-
2. I really take time tried to make the best solution or explaination, because I wanted to help others like me. If you like my answer, a star on GitHub means a lot to me. <https://github.com/wuduhren/leetcode-python>.
4+
2. I really take time tried to make the best solution or explaination.
5+
Because I wanted to help others like me.
6+
If you like my answer, a star on GitHub means a lot to me.
7+
https://github.com/wuduhren/leetcode-python>
58

69
3. The question is at `https://leetcode.com/problems/the-file-name/`.
710

add-digits.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
#https://leetcode.com/problems/add-digits/
22
class Solution(object):
33
def addDigits(self, num):
4-
if num==0: return 0
5-
6-
while len(str(num))>1:
7-
counter = 0
8-
for i in str(num):
9-
counter+=int(i)
10-
num = counter
11-
return num
4+
if num<10: return num
5+
total = 0
6+
while num>9:
7+
total = 0
8+
for d in str(num):
9+
total+=int(d)
10+
num = total
11+
return num
12+
13+
"""
14+
I really take time tried to make the best solution or explaination.
15+
Because I wanted to help others like me.
16+
If you like my answer, a star on GitHub means a lot to me.
17+
https://github.com/wuduhren/leetcode-python
18+
"""

0 commit comments

Comments
 (0)