Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 87cbe36

Browse files
add 728.py
1 parent 50110c8 commit 87cbe36

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎py2/728. Self Dividing Numbers.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution(object):
2+
def selfDividingNumbers(self, left, right):
3+
"""
4+
:type left: int
5+
:type right: int
6+
:rtype: List[int]
7+
"""
8+
return filter(self._is_self_dividing_num, xrange(left, right+1))
9+
10+
def _is_self_dividing_num(self, num):
11+
digits = [int(i) for i in str(num)]
12+
if 0 not in digits:
13+
for i in digits:
14+
if num % i:
15+
break
16+
else:
17+
return True
18+
return False
19+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /