pythonchallenge(0-9)
来源:互联网 发布:淘宝上怎么买氰化钾 编辑:程序博客网 时间:2024/05/29 14:54
0.
2**38
1.
方法一:
input
=
"g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp.\
bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.\
kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
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
print
output
mymap(
input
)
mymap(
'map'
)
方法二:
import
string
s
=
"g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp.\
bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.\
kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
leet
=
string.maketrans(
'abcdefghijklmnopqrstuvwxyz'
,
'cdefghijklmnopqrstuvwxyzab'
)
print
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()]
print
''.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)
print
''.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
):
print
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)
print
'\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'
) as zf:
while
(
1
):
comment.append(zf.getinfo(currentfile).comment)
data
=
zf.read(currentfile)
nextnum
=
data.split()[
-
1
]
if
str
.isdigit(nextnum):
currentfile
=
nextnum
+
'.txt'
else
:
print
data
break
print
''.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
])
print
asi
l
=
[
105
,
110
,
116
,
101
,
103
,
114
,
105
,
116
,
121
]
print
''.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)
print
decompressed_un,decompressed_pw
解个压缩就过了。。比想象中容易一点,不过要看出un和pw是bz2压缩后的字符。(1.图片有一直蜜蜂,发音bee有提示 2.对bz2压缩后的形式熟悉)
0 0
- pythonchallenge(0-9)
- pythonchallenge--9
- PythonChallenge(0)
- pythonchallenge--0
- pythonchallenge 0
- PythonChallenge第9题
- PythonChallenge Mission 9
- PythonChallenge Level 0
- pythonchallenge 【第0题】
- pythonchallenge第0关
- [PythonChallenge]第0关
- 【pythonchallenge】【问题0】
- PythonChallenge第0题
- PythonChallenge Mission 0
- PythonChallenge
- pythonchallenge
- PythonChallenge 挑战之路 Level-9
- PythonChallenge 挑战之路 Level-0
- centos6.5 安装 MySQL5.7
- day05 数组 排序
- nginx取资源要用get方式,post会失败
- Spark SQL 官方文档-中文翻译
- ROS学习笔记(三)::RVIZ::wiki::translation::catkin:一:Creating a workspace for catkin
- pythonchallenge(0-9)
- 08-2 UISwitch and UIStepper
- 38 用break和continue改变流程 课后
- DataSet之增删改查操作(DataGridView绑定)
- python os.path模块
- (深搜) — — hdu 1016
- ADO.NET常用方法释义
- python challenge(9-18)
- 09 UIScrollView 、 UIPageControl