六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 20|回复: 0

Python Challenge (level 14)

[复制链接]

升级  62%

120

主题

120

主题

120

主题

举人

Rank: 3Rank: 3

积分
386
 楼主| 发表于 2013-2-7 15:01:20 | 显示全部楼层 |阅读模式
URI: http://www.pythonchallenge.com/pc/return/italy.html
Username: huge; password: file
说明:

解题答案:
import Image, mathdef get_pixel(t):    t = (100 * 100 - 1) - t    shell = int((math.sqrt(t) + 1) / 2)    leg = 0 if (shell == 0) else int((t - (2 * shell - 1) ** 2) / 2 / shell)    elt = t - (2 * shell - 1) ** 2 - 2 * shell * leg - shell + 1        if leg == 0:        x, y = shell, elt    elif leg == 1:        x, y = -elt, shell    elif leg == 2:        x, y = -shell, -elt    else:        x, y = elt, -shell    return (49 + x, 50 - y)# Download the image from: http://www.pythonchallenge.com/pc/return/wire.pnginput = Image.open("wire.png")output = Image.new("RGB", (100, 100))for i, px in enumerate(input.getdata()):    output.putpixel(get_pixel(i), px)output.save("new.jpg")
过关答案:
cat
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表