My LeetCode grinding. Trying to do a problem a day.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.py 482B

12345678910111213141516
  1. class Solution:
  2. def selfDividingNumbers(self, left, right):
  3. result = []
  4. for x in range(left, right + 1):
  5. ok = True
  6. for c in str(x):
  7. if c == '0' or x % int(c) != 0:
  8. ok = False
  9. break
  10. if ok:
  11. result.append(x)
  12. return result
  13. s = Solution()
  14. print("Expected: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]")
  15. print("Got:", str(s.selfDividingNumbers(1, 22)))