美文网首页
Python Challenge[16]

Python Challenge[16]

作者: Recgat | 来源:发表于2017-02-11 21:48 被阅读0次

[Level 16]


Title: let me get this straight

一张图片,唯一的提示就是标题了。需要把粉色条(长度为5px)对齐。图片模式为p(8-bit pixels, mapped to any other mode using a color palette),大小为640*480px,粉色的像素值为195

from PIL import Image
img=Image.open('mozart.gif')
data=list(img.getdata())
for i in range(480):
  t=data[640*i:].index(195)
  data[640*i:640*(i+1)]=data[640*i+t:640*(i+1)]+data[640*i:640*i+t]
img.putdata(data)
img.show()

或许这样好点:

for off in range(0,len(data),width):
  line=data[off:off+width]
  idx=line.index(195)
  data[off:off+width]=line[idx:]+line[:idx]

得到romance[Level 17]

小结

粉色条“拉直”后即可。

Python Challenge Wiki

正则替换?或许不错。

More

相关文章

  • Python Challenge[16]

    [Level 16] Title: let me get this straight 一张图片,唯一的提示就是标题...

  • Python挑战:00~03关

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

  • Python挑战:04-05关

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

  • 比赛及资源 summary

    https://luna16.grand-challenge.org/download/ -> downloade...

  • The Python Challenge(5)

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

  • The Python Challenge(8)

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

  • The Python Challenge(9)

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

  • The Python Challenge(2)

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

  • The Python Challenge(3)

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

  • The Python Challenge(4)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面提示: 并结合页面源码中的内容,有如下代码:...

网友评论

      本文标题:Python Challenge[16]

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