i almost give up every day.
yesterday , i give up again.!
python challenge .我玩不下去了,,,,感觉那些线索在玩文字游戏。 英文的文字游戏!
让你猜python module 里的东西!
我英语没那么好哦....好是别费太多时间在上面好了...我还不够格。
还是另找学习python 的路好了...不过根据我的水平....还是乖乖跟着做习题好...
不过我很不乖,,完拉。
眼高手低...
继续克服,继续锻炼
0o[.___.]
Thu, 28 Jan 2010 06:08:39 +0800
i almost give up every day.
yesterday , i give up again.!
python challenge .我玩不下去了,,,,感觉那些线索在玩文字游戏。 英文的文字游戏!
让你猜python module 里的东西!
我英语没那么好哦....好是别费太多时间在上面好了...我还不够格。
还是另找学习python 的路好了...不过根据我的水平....还是乖乖跟着做习题好...
不过我很不乖,,完拉。
眼高手低...
继续克服,继续锻炼
Sat, 23 Jan 2010 08:02:02 +0800
这一关就比较诡异了...
peak hell sound fmiliar ?
sound fmiliar?!! 马上上网找hints. => pickle
pickle 是啥!? 去官网看hints. => Global Module Index
原来是一个module.....
pickle 是一个将python object 转换成 ASCII 的module. 当然,可以互转。也可以转成binary。
于是,该页面的源码里给出了一个叫做 'banner.p'的文件,里面就有一堆ASCII码了。
解出来是什么呢!? 一堆list object 里包含着数个 tuple , tuple 包含这一组类似于(' ',4), ('#',6')
看不懂,这是啥!? 乖乖继续到官网看 => banner 是一个*unix的命令....运行看看!
噢,终于明白了,原来那些tuple就是告诉你 空格要大印多少个,'#'要打印多少个。
每个list 里的 tuple里的数字加起来都是一样的!
很简短,却花了那么多功夫,折腾。
here go
import pprint, pickle
file = open('banner.p','rb')
data = pickle.load(file)
for c in data:
line = ""
for x in c:
for i in range(x[1]):
line += x[0]
pprint.pprint(line)
结果是!哇!真好看的说(解题后的喜悦所影响,哈哈). next. is level 6. cheer
' ' ' ##### ##### ' ' #### #### ' ' #### #### ' ' #### #### ' ' #### #### ' ' #### #### ' ' #### #### ' ' #### #### ' ' ### #### ### ### ##### ### ##### ### ### #### ' ' ### ## #### ####### ## ### #### ####### #### ####### ### ### #### ' ' ### ### ##### #### ### #### ##### #### ##### #### ### ### #### ' ' ### #### #### ### ### #### #### #### #### ### #### #### ' ' ### #### #### ### #### #### #### #### ### ### #### ' '#### #### #### ## ### #### #### #### #### #### ### #### ' '#### #### #### ########## #### #### #### #### ############## #### ' '#### #### #### ### #### #### #### #### #### #### #### ' '#### #### #### #### ### #### #### #### #### #### #### ' ' ### #### #### #### ### #### #### #### #### ### #### ' ' ### ## #### #### ### #### #### #### #### #### ### ## #### ' ' ### ## #### #### ########### #### #### #### #### ### ## #### ' ' ### ###### ##### ## #### ###### ########### ##### ### ######' ' '
Sat, 23 Jan 2010 07:50:42 +0800
这关给了个图片,点开图片会给出一句话
and the next nothing is ***** , ****是数字
初始数字是12345
title 是 follow the chain
试了几次后会提示,说你在手动......
其他提示在页面中,没什么特别的,找出数字,循环。一直到loop....loop.....
结果就没有出现数字的那一页。以下为解题:
#!/bin/env python
import urllib
import re
ourl = "http://www.pythonchallenge.com/pc/def/linkedlist.php";
code = "12345"
for i in range(400):
params = urllib.urlencode({'nothing':code})
#print i,
try:
f = urllib.urlopen(ourl+'?%s' % params)
for line in f.readlines():
m = re.findall('\d+',line)
print '>> '+line
if len(m) != 0:
#there several number group at midway
#chose the last one
code = m[-1]
else:
break
print '<<' + code
except Exception, IOError:
raise IOError
好像忘记看其他人怎么解了....
Sun, 10 Jan 2010 08:23:48 +0800
python challenge 是一个闯关游戏...编程游戏. 主要用python 语言解题. 也可以用其他语言...
前两关就不说了..现在开始记录下过level3的点:
刚开始,没主要到页面的title是 re (<html><title>re</title>......</html>). re 是python 的正则表达式模块.
这说明这个level 要用到 regular expression. 但我用了一般的 if , for 。如下:
#!/bin/env python
analyze = open('source').read().strip().replace('\n',"")
box = [x for x in analyze[:8]]
box.insert(0,'0')
#print "".join(box)
#print "%s" % analyze
re = ""
for s in analyze[7:]:
box.remove(box[0])
box.append(s)
#print "".join(box)
if "".join(box[1:4]).isupper() and "".join(box[-4:-1]).isupper():
if "".join(box[0]).islower() and "".join(box[-1:]).islower():
if "".join(box[4]).islower():
#print "".join(box)
re += "".join(box[4])
print re
在论坛看完7页的帖子后(都是给hints '提示,') 。发现我忽略了一个明显的提示......EXACTLY...
给出一个hints : you should search 'xXXXxXXXx' instead of 'XXXxXXX'.
oh...that's it!
当然有个hints: use re model。
我之前也发现了 re. 但是不知道是啥意。
下面是我的正则,还没去看大家的解法:
下面的source 是一个文件,存放了一大串字符串....
-E : 使用 egrep; -F: 使用 fgrep
-o : 只显示匹配的那部分,而不是正行。
--color: 在匹配的行中用特别的颜色凸显出匹配部分
grep -E -o '[a-z]{1}[A-Z]{3}[a-z]{1}[A-Z]{3}[a-z]{1}' source