Created
May 17, 2018 07:10
-
-
Save lttzzlll/7b0c9f76e14d1733f36c8692295bdde8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import random | |
def is_repeat(n): | |
n_str = str(n) | |
for i in range(len(n_str) - 1): | |
if n_str[i] == n_str[i + 1]: | |
return False | |
return True | |
def firstnum(n): | |
while True: | |
n += 1 | |
if is_repeat(n): | |
return n | |
return None | |
class FirstNumTest(unittest.TestCase): | |
def test_first_num(self): | |
n = 889911 | |
next_n = 890101 | |
res = firstnum(n) | |
self.assertEqual(res, next_n) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
找到第一个不重复的数字。