Skip to content

Commit 6f42638

Browse files
committed
add 28, 29
1 parent 2f27429 commit 6f42638

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

pycl/pycl28.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#-*- coding:utf-8 -*-
2+
'''
3+
Created on 2017年5月9日
4+
5+
@author: huangjiaxin
6+
'''
7+
from PIL import Image
8+
import numpy as np
9+
10+
def main():
11+
im = Image.open('bell.png')
12+
imdata = list(im.getdata())
13+
imdata = np.array(imdata)
14+
size = im.size
15+
imdata = imdata.reshape((size[1], size[0], -1))
16+
imdata_g = imdata[:, :, 1]
17+
diff = np.abs(imdata_g[:, 0::2] - imdata_g[:, 1::2])
18+
idx = np.where(diff != 42)
19+
msg = diff[idx]
20+
print ''.join(chr(i) for i in msg)
21+
print 'Guido van Rossum'.split()[0]
22+
23+
if __name__ == '__main__':
24+
main()

pycl/pycl29.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#-*- coding:utf-8 -*-
2+
'''
3+
Created on 2017年5月9日
4+
5+
@author: huangjiaxin
6+
'''
7+
import urllib
8+
import bz2
9+
10+
def main():
11+
html = urllib.urlopen('http://repeat:switch@www.pythonchallenge.com/pc/ring/guido.html').read()
12+
html = html.split('\n')[12:]
13+
data = [chr(len(i)) for i in html]
14+
print bz2.decompress(''.join(data))
15+
16+
if __name__ == '__main__':
17+
main()

0 commit comments

Comments
 (0)