Python Challenge[28]

2017-03-03  本文已影响0人  Recgat

[Level 28]


Title: many pairs ring-ring

RING-RING-RING say it out loud,但没say出什么来。

green。green.html显示yes! green!。取出G通道的数据,成对相减大多数的绝对值为42,那么搜集绝对值不是42的数值,转换为 ascii 码。

from PIL import Image
img = Image.open('bell.png')
data = [d[1] for d in img.getdata()]
s = [abs(data[i]-data[i+1]) for i in range(0,len(data),2) if abs(data[i]-data[i+1])!=42]
print(bytes(s).decode())

得到:

whodunnit().split()[0] ?

whodunnit -> "Who [has] done it?" or "Who did it"。Python的作者是Guido van Rossum,所以是guido[Level 29]

小结

可以这样取出G通道的数据:
data = list(im.split()[1].getdata())
或这样取出绝对值不为42的数据:

diff = [abs(a - b) for a, b in zip(green[0::2], green[1::2])]
filtered = list(filter(lambda x: x != 42, diff))

Python Challenge Wiki

上一篇下一篇

猜你喜欢

热点阅读