编程语言
首页 > 编程语言> > pythonchallenge Level 14

pythonchallenge Level 14

作者:互联网

第14关地址:http://www.pythonchallenge.com/pc/return/italy.html

账号:huge 密码:file

一个逆时针螺旋面包,下方还有一张小图

查看源码,标题是walk around

提示信息:remember: 100*100 = (100+99+99+98) + (...  

 

wire.png 刚好是100*100,也就是要把wire.png的像素点重排,按照逆时针一圈一圈排列

from PIL import Image

img = Image.open('wire.png')
print(img.size) # (10000, 1)
newImg = Image.new(img.mode,(100,100))

x0,y,num = 0,0,0
while x0 < 10000:
    for x in range(num,100-num):
        newImg.putpixel((x, y), img.getpixel((x0, 0)))
        x0 += 1
    for y in range(num,99-num):
        newImg.putpixel((x, y), img.getpixel((x0, 0)))
        x0 += 1
    for x in range(99-num,num,-1):
        newImg.putpixel((x, y), img.getpixel((x0, 0)))
        x0 += 1
    for y in range(98-num,num,-1):
        newImg.putpixel((x, y), img.getpixel((x0, 0)))
        x0 += 1
    num += 1
newImg.save("newImg14.png")

 

得到一只猫,打开http://www.pythonchallenge.com/pc/return/cat.html

 

得到提示信息:and its name is uzi. you'll hear from him later.

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

标签:14,pythonchallenge,Level,newImg,img,num,100,getpixel,x0
来源: https://www.cnblogs.com/nicole-zhang/p/15557532.html