pythonchallenge_level10

level10

地址:http://www.pythonchallenge.com/pc/return/bull.html
源码:git@code.aliyun.com:qianlizhixing12/PythonChallenge.git。
问题:观察数字规律。

#!/usr/bin/env python3
# -*- coding:UTF-8 -*-

# Level 10

rstlist = ["1"]

for i in range(1,31):
    a = 0
    schr = "0"
    nchr = 0
    for tmp in rstlist[i - 1]:
        if tmp == schr:
            nchr = nchr + 1
        else:
            a = a * 100 + nchr * 10 + int(schr)
            schr = tmp
            nchr = 1

    a = a * 100 + nchr * 10 + int(schr)
    rstlist.append(str(a))

print("Level 10:", len(rstlist[30]))
时间: 2024-09-20 17:53:28

pythonchallenge_level10的相关文章