Python教程

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

这篇关于pythonchallenge Level 14的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!