pythonchallenge(0-9)
2015-12-18 20:18
701 查看
0.
2**38
1.
方法一:
方法二:
2. http://www.pythonchallenge.com/pc/def/ocr.htm
3.http://www.pythonchallenge.com/pc/def/equality.html
恰好3个大写字母做保镖。
4. http://www.pythonchallenge.com/pc/def/linkedlist.php
保存到文本中,再找规律。
5. http://www.pythonchallenge.com/pc/def/peak.html
我还以为要"pronounce it"音频处理呢。。结果"peakhell"暗示"pickle",用pickle load,然后' '与'#'恢复出字符组成的字channel.
6. http://www.pythonchallenge.com/pc/def/channel.html
这道题我也是败给它了。先是领会出把url中的html换成zip,这样就可以下载zip文件了(会自动弹出对话框下载),然后找到readme.txt根据提示,类似第5题一样往下搜索,最后结果是Collect the comments,原来每个zip文件都一个信息,信息里包含了comment。
7. http://www.pythonchallenge.com/pc/def/oxygen.html
8. http://www.pythonchallenge.com/pc/def/integrity.html
解个压缩就过了。。比想象中容易一点,不过要看出un和pw是bz2压缩后的字符。(1.图片有一直蜜蜂,发音bee有提示 2.对bz2压缩后的形式熟悉)
2**38
1.
方法一:
input
=
"g fmncwmsbgblr rpylqjyrcgr zw fylb. rfyrq ufyr amknsrcpq ypcdmp.\
bmgle gr glzw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.\
kyicrpylq() gq pcamkkclbcb. lmu ynnjw mlrfcspj."
def
mymap(
input
):
output
=
''
for
x
in
input
:
if
'a'
<
=
x
and
'x'
>
=
x:
output
+
=
chr
(
ord
(x)
+
2
)
elif
x
=
=
'y'
:
output
+
=
'a'
elif
x
=
=
'z'
:
output
+
=
'b'
else
:
output
+
=
x
output
mymap(
input
)
mymap(
'map'
)
方法二:
import
string
s
=
"g fmncwmsbgblr rpylqjyrcgr zw fylb. rfyrq ufyr amknsrcpq ypcdmp.\
bmgle gr glzw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.\
kyicrpylq() gq pcamkkclbcb. lmu ynnjw mlrfcspj."
leet
=
string.maketrans(
'abcdefghijklmnopqrstuvwxyz'
,
'cdefghijklmnopqrstuvwxyzab'
)
string.translate(s,leet)
2. http://www.pythonchallenge.com/pc/def/ocr.htm
import
sys,urllib
import
re
url
=
"http://www.pythonchallenge.com/pc/def/ocr.html"
wp
=
urllib.urlopen(url)
content
=
wp.read()
p
=
re.
compile
(r
'<!--([\s\S]*?)-->'
)
out
=
p.findall(content)[
1
]
res
=
[c
for
c
in
out
if
c.isalpha()]
''.join(res)
3.http://www.pythonchallenge.com/pc/def/equality.html
恰好3个大写字母做保镖。
import
sys,urllib
import
re
url
=
"http://www.pythonchallenge.com/pc/def/equality.html"
wp
=
urllib.urlopen(url)
content
=
wp.read()
p
=
re.
compile
(r
'[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]'
)
out
=
p.findall(content)
''.join(out)
4. http://www.pythonchallenge.com/pc/def/linkedlist.php
import
sys,urllib
import
re
url
=
"http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345"
output
=
open
(
'result.txt'
,
'w'
)
for
i
in
range
(
400
):
i
output.write(url
+
'\n'
)
content
=
urllib.urlopen(url).read()
num
=
content.split()[
-
1
]
output.write(content
+
'\n'
)
token
=
url.split(
'='
)
token[
-
1
]
=
'='
+
num
url
=
''.join(token)
output.close()
保存到文本中,再找规律。
5. http://www.pythonchallenge.com/pc/def/peak.html
import
pickle
f
=
open
(
'banner.p'
)
data
=
pickle.load(f)
'\n'
.join(''.join(p[
0
]
*
p[
1
]
for
p
in
row)
for
row
in
data)
f.close()
我还以为要"pronounce it"音频处理呢。。结果"peakhell"暗示"pickle",用pickle load,然后' '与'#'恢复出字符组成的字channel.
6. http://www.pythonchallenge.com/pc/def/channel.html
import
zipfile
currentfile
=
"90052.txt"
comment
=
[]
with zipfile.ZipFile(
'channel.zip'
,mode
=
'r'
) aszf:
while
(
1
):
comment.append(zf.getinfo(currentfile).comment)
data
=
zf.read(currentfile)
nextnum
=
data.split()[
-
1
]
if
str
.isdigit(nextnum):
currentfile
=
nextnum
+
'.txt'
else
:
data
break
''.join(comment)
这道题我也是败给它了。先是领会出把url中的html换成zip,这样就可以下载zip文件了(会自动弹出对话框下载),然后找到readme.txt根据提示,类似第5题一样往下搜索,最后结果是Collect the comments,原来每个zip文件都一个信息,信息里包含了comment。
7. http://www.pythonchallenge.com/pc/def/oxygen.html
from
PIL
import
Image
img
=
Image.
open
(
'oxygen.png'
)
pix
=
img.load()
width
=
img.size[
0
]
center
=
img.size[
1
]
/
2
asi
=
''
for
x
in
range
(
0
,width,
7
):
asi
=
asi
+
chr
(pix[x,center][
0
])
asi
l
=
[
105
,
110
,
116
,
101
,
103
,
114
,
105
,
116
,
121
]
''.join([
chr
(i)
for
i
in
l])
8. http://www.pythonchallenge.com/pc/def/integrity.html
import
bz2
compressed_un
=
"BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084"
compressed_pw
=
"BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08"
decompressed_un
=
bz2.decompress(compressed_un)
decompressed_pw
=
bz2.decompress(compressed_pw)
decompressed_un,decompressed_pw
解个压缩就过了。。比想象中容易一点,不过要看出un和pw是bz2压缩后的字符。(1.图片有一直蜜蜂,发音bee有提示 2.对bz2压缩后的形式熟悉)
相关文章推荐
- python爬豆瓣电影Top250
- Python学习笔记(一)压缩与解压缩文件
- [Python标准库]difflib——比较序列
- python : 批量下载R语言库包
- ICMP隧道之端口转发(Python)
- 也说性能测试,顺便说python的多进程+多线程、协程
- Python批量添加库搜索路径
- 创建对称矩阵(numpy)
- python开源库——h5py快速指南
- Python 函数作为参数传递
- windows下Python3.4安装numpy时出现 “Unable to find vcvarsall.bat ”
- Python
- python 之日期时间处理
- numpy 基础知识
- Python -- 字典转换为列表
- 用Python计算MovieLens 100k数据集中男性女性用户评分的标准差
- python基础学习---2
- python正则表达式
- 升级python2.7.6出现的问题
- 显示python的site-packages路径