Python Challenge (level 22)

xiaoxiao2026-09-14  13

URI: [url]http://www.pythonchallenge.com/pc/hex/copper.html[/url] Username: butter; password: fly 说明: — 解题方法: import Image, ImageSequenceimg = Image.open("white.gif") # http://www.pythonchallenge.com/pc/hex/white.gifout = Image.new("P", (125, 125))pix = out.load()pos = [25, 25]for x in [list(f.getdata()).index(8) for f in ImageSequence.Iterator(img)]: if x == 19698: pos[0] -= 1 pos[1] -= 1 elif x == 19700: pos[1] -= 1 elif x == 19702: pos[0] += 1 pos[1] -= 1 elif x == 20098: pos[0] -= 1 elif x == 20100: pos = [pos[0] + 10, pos[1] + 10] elif x == 20102: pos[0] += 1 elif x == 20498: pos[0] -= 1 pos[1] += 1 elif x == 20500: pos[1] += 1 elif x == 20502: pos[0] += 1 pos[1] += 1 pix[pos[0], pos[1]] = 200out.save("solution.png") 过关答案: bonus 相关资源:pythonchallenge level2官方方法集
转载请注明原文地址: https://www.6miu.com/read-5052667.html

最新回复(0)