现在的位置: 首页 > 综合 > 正文

pythonchallenge–10

2013年10月12日 ⁄ 综合 ⁄ 共 287字 ⁄ 字号 评论关闭
a = '1'
for i in xrange(30):
    pos = 0
    tmp = ''
    str_len = len(a)
    while pos < str_len:
        count = 1
        while pos+1<str_len and a[pos] == a[pos+1]:
            count += 1
            pos += 1

        tmp += '%d%s'%(count,a[pos])
        pos += 1
    a = tmp
print(len(a))

纠结!

题目链接:http://www.pythonchallenge.com/pc/return/bull.html

下一题链接:http://www.pythonchallenge.com/pc/return/5808.html

抱歉!评论已关闭.