pythonchallenge Level 31

第31关地址:http://www.pythonchallenge.com/pc/ring/grandpa.html

用户名:repeat  密码:switch

查看源码

标题:Where am I?

新链接需要用户名密码:http://www.pythonchallenge.com/pc/rock/grandpa.html

提示:short break, this ***REALLY*** has nothing to do with Python

搜图片之后发现是泰国苏梅岛 Koh Samui Thailand

去掉空格全部小写之后,得到用户名 kohsamui  密码 thailand 

点击石头打开http://www.pythonchallenge.com/pc/rock/grandpa.html 登录

That was too easy. You are still on 31... 显示仍在第31关

查看源码

标题:UFOs ?

图片名称:mandelbrot.gif

查了下 Mandelbrot Set(曼徳勃罗特集)

一组数值:left="0.34" top="0.57" width="0.036" height="0.027" iterations="128"

from PIL import Image

img = Image.open("mandelbrot.gif")
w, h = img.size # 640 480
left = 0.34
top = 0.57
width = 0.036
height = 0.027
iterations = 128
result = []
for y in range(h - 1, -1, -1):
    for x in range(0, w):
        z = 0 + 0j
        c = complex(left + x * width / w, top + y * height / h)
        for i in range(iterations):
            z = z * z + c
            if abs(z) > 2:
                break
        result.append(i)

img2 = img.copy()
img2.putdata(result)
img2.save("img2_31.gif")

得到一张新图

对比新图和mandelbrot.gif差异

diff = [(a-b) for a, b in zip(list(img.getdata()), result) if a != b]
print(diff)
print(len(diff))

diff都是16或-16,长度为1679

img3 = Image.new('L', (23, 73))
img3.putdata([i>0 and 255 or 0 for i in diff])
img3.save("img3_31.gif")

得到一张图

搜索图片可得到 arecibo(百度搜不到,按照网上资料使用Google搜的wikipedia)

本关没看明白,参考了 https://www.jianshu.com/p/e0639a1baf1c 

获得下一关地址:http://www.pythonchallenge.com/pc/rock/arecibo.html

posted @ 2021-12-07 10:06  OTAKU_nicole  阅读(57)  评论(0编辑  收藏  举报