Python Challenge (level 14)

xiaoxiao2026-09-04  7

URI: [url]http://www.pythonchallenge.com/pc/return/italy.html[/url] 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 相关资源:pythonchallenge level2官方方法集
转载请注明原文地址: https://www.6miu.com/read-5052383.html

最新回复(0)