Skip to content

Instantly share code, notes, and snippets.

@lttzzlll
Created May 17, 2018 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lttzzlll/7b0c9f76e14d1733f36c8692295bdde8 to your computer and use it in GitHub Desktop.
Save lttzzlll/7b0c9f76e14d1733f36c8692295bdde8 to your computer and use it in GitHub Desktop.
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()
@lttzzlll
Copy link
Author

找到第一个不重复的数字。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment