My LeetCode grinding. Trying to do a problem a day.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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)))