http://www.pythonchallenge.com/pc/return/italy.html
照例输入huge file进入。
图就不放了,反正就是那个页面,标题是 walk around,那我们就到处逛一逛哈,面包,一个色板(估计要查一查它的像素信息)
<html>
<head>
<title>walk around</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<center>
<img src="italy.jpg"><br>
<br>
<!-- remember: 100*100 = (100+99+99+98) + (... -->
<img src="wire.png" width="100" height="100">
</body>
</html>
这里有个comment提示,另外有个wire.png,点进去没图片,估计又是藏着什么文本。
先针对怀疑的两点试试看看。注意这里的httpbasicAuth认证。
(1)wire.png.
import requests.auth
url = 'http://www.pythonchallenge.com/pc/return/wire.png'
auth = requests.auth.HTTPBasicAuth('huge', 'file')
response = requests.post(url, auth=auth)
response.encoding = response.apparent_encoding
print(response.content.decode())
报错提示utf-8无法解码??wtf??稍等保存一下。
看看像素信息呢?
# -*- coding: utf-8 -*-
from PIL import Image
image = Image.open('wire.png')
width, height = image.size
# print(width, height)
pix = image.load()
for x in range(width):
print(pix[x, 0.5])
输出结果是10000个元组,看起来也不是这么回事啊~~
(2)就是这个注释了:100*100 = (100+99+99+98) + (… – 什么意思?我先想想,卡个壳啦~
中午试了一下,感觉这样结果规律性较强一点,不知道会不会拐进死胡同,思路是: (100+99+99+98)补上(0+1+1+2), 正好是400,如果凑成10000,就得有25组 数据对,即50组数据,先试试:
l = [[i, i-1, i-1, i-2] for i in range(100, 0, -2)]
for x in l:
print(x)
或者这样:
def c_list(num):
return [num, num-1, num-1, num-2]
l = list(map(c_list, range(100,0,-2)))
这些列表之和正好是100*100,,
[100, 99, 99, 98]
[98, 97, 97, 96]
[96, 95, 95, 94]
[94, 93, 93, 92]
[92, 91, 91, 90]
[90, 89, 89, 88]
[88, 87, 87, 86]
[86, 85, 85, 84]
[84, 83, 83, 82]
[82, 81, 81, 80]
[80, 79, 79, 78]
[78, 77, 77, 76]
[76, 75, 75, 74]
[74, 73, 73, 72]
[72, 71, 71, 70]
[70, 69, 69, 68]
[68, 67, 67, 66]
[66, 65, 65, 64]
[64, 63, 63, 62]
[62, 61, 61, 60]
[60, 59, 59, 58]
[58, 57, 57, 56]
[56, 55, 55, 54]
[54, 53, 53, 52]
[52, 51, 51, 50]
[50, 49, 49, 48]
[48, 47, 47, 46]
[46, 45, 45, 44]
[44, 43, 43, 42]
[42, 41, 41, 40]
[40, 39, 39, 38]
[38, 37, 37, 36]
[36, 35, 35, 34]
[34, 33, 33, 32]
[32, 31, 31, 30]
[30, 29, 29, 28]
[28, 27, 27, 26]
[26, 25, 25, 24]
[24, 23, 23, 22]
[22, 21, 21, 20]
[20, 19, 19, 18]
[18, 17, 17, 16]
[16, 15, 15, 14]
[14, 13, 13, 12]
[12, 11, 11, 10]
[10, 9, 9, 8]
[8, 7, 7, 6]
[6, 5, 5, 4]
[4, 3, 3, 2]
[2, 1, 1, 0]
接下来如何处理这些列表呢?img src=“wire.png” width=“100” height=“100”,告诉我们wire.png 是个100 * 100的图,但是呢,实际上却是个10000 * 1的。直觉告诉我,这里有坑。再想想。
=======================
(2天后)
今天在看一个日本妇人在那里绕毛线,从一个线绕成一个团,忽然想到这个是不是也是这样,将10000 * 1的线绕成100 * 100的图片,说做就做试试看!
from PIL import Image
def c_list(num):
return [num, num - 1, num - 1, num - 2]
steps = []
ls = list(map(c_list, range(100, 0, -2)))
for _ in ls:
for __ in _:
steps.append(__)
origin = Image.open('wire.png')
result = Image.new(origin.mode, (100, 100))
direction = [(1, 0), (0, 1), (-1, 0), (0, -1)]
x, y = -1, 0 #为了防止+100后超出100*100的边界
count = 0
for i in range(len(steps)):
for j in range(steps[i]):
x = x + direction[i % 4][0]
y = y + direction[i % 4][1]
result.putpixel((x, y), origin.getpixel((count, 0)))
count += 1
result.show()
出来一个可爱的小猫咪:
哈哈,看来猜测没错了,将url改成cat
记住作者的uzi吧,图片上还没有每关的数字,表示就是还没通关的意思,还得搞点什么??
( after sleep overnight)
原来就是改成uzi.html
http://www.pythonchallenge.com/pc/return/uzi.html
进入第15关!