街角_祝福

导航

pythonchallenge--10

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

posted on 2012-08-13 10:21  街角_祝福  阅读(139)  评论(0编辑  收藏  举报