在此插入代码
def pali(): '''只有奇数位数字才有可能是回数,''' n = 100 while True: n = n +1 if len(str(n)) % 2 == 1: yield n else: n = n * 10 -1
def _is_pali(n): return lambda x: str(x) == str(x)[::-1]
def palindrome(): it = pali() while True: n = next(it) it = filter(_is_pali(n), it) yield n
for x in palindrome(): if x < 100000: print(x, end = ',') else: break
Sign in to make a reply
默_kk
def pali(): '''只有奇数位数字才有可能是回数,''' n = 100 while True: n = n +1 if len(str(n)) % 2 == 1: yield n else: n = n * 10 -1
def _is_pali(n): return lambda x: str(x) == str(x)[::-1]
def palindrome(): it = pali() while True: n = next(it) it = filter(_is_pali(n), it) yield n
for x in palindrome(): if x < 100000: print(x, end = ',') else: break