美文网首页
Python Challenge[10]

Python Challenge[10]

作者: Recgat | 来源:发表于2017-02-09 23:01 被阅读0次

[Level 10]

Title: what are you looking at?

len(a[30]) = ?

除此之外,源码中没其他提示,图片牛的区域可点击,进去的网页显示a = [1, 11, 21, 1211, 111221,找到规律,再求出len(a[30])即可。

import re
e = '1'
a = [e]
for i in range(30):
  temp = ''
  while e:
    x = e[0]
    c = re.match('{0}+'.format(x),e).end()
    temp += str(c) + x
    e = e[c:]
  e = temp
  a.append(e)
print(len(a[30]))#len(e)

21表示2个1(11),1211表示1个2,1个1(21)略坑。最终答案是5808[Level 11]

Python Challenge Wiki

按此规律产生的字符串仅含有1、2和3三种字符,由此,产生字符串的方法也更多样了。如:

a = '1'
for i in range(30):
a = ''.join(map(lambda x: repr(len(x))+x[0], re.findall('(1+|2+|3+)', a)))
print(len(a))


或者`a = ''.join([str(len(i+j))+i for i,j in re.findall(r'(\d)(\1*)', a)])`


####[More](http://wiki.pythonchallenge.com/index.php?title=Level10:Main_Page)

相关文章

  • Python挑战:00~03关

    Python Challenge Python Challenge 00 网址: http://www.pytho...

  • Python Challenge[10]

    [Level 10] Title: what are you looking at? len(a[30]) = ?...

  • Python挑战:04-05关

    Python Challenge Python Challenge 04 现在,我们来挑战第四关,从第三关的结果,...

  • 网站的十年挑战 / 宫崎骏的手绘情节 / 绝地求生的求生欲(20

    1. 网站们的 10-year challenge 脸书发起的10 year challenge让大家纷纷感慨岁月...

  • SQLi-LABS Page-4 (Challenges) le

    Lesson - 54 GET - Challenge - Union - 10 queries allowed ...

  • The Python Challenge(5)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面源码提示: 再点击页面图片显示: 可知是需要...

  • The Python Challenge(8)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 页面和源码中无任何提示,但图片中有一条很明显的灰度线...

  • The Python Challenge(9)

    问题链接 问题链接如下: 答案链接 答案链接如下: 登陆用户名密码为huge和file。 解题思路 阅读源码有如下...

  • The Python Challenge(2)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 将页面给定的字符串根据给定规则进行替换即可,规则如下...

  • The Python Challenge(3)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面提示: 阅读源码,有如下内容: 编写代码从中...

网友评论

      本文标题:Python Challenge[10]

      本文链接:https://www.haomeiwen.com/subject/sugwittx.html