File tree 3 files changed +46
-0
lines changed
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ import download_file
2
+
3
+ from PIL import Image
4
+
5
+
6
+ def main ():
7
+ url = "http://www.pythonchallenge.com/pc/ring/bell.png"
8
+ file_path = "ring/bell.png"
9
+ username = "repeat"
10
+ password = "switch"
11
+ # first_step(url, file_path, username, password)
12
+ second_step (file_path )
13
+
14
+
15
+ def first_step (url , file_path , username , password ):
16
+ download_file .download_with_auth (url , file_path , username , password )
17
+
18
+
19
+ def second_step (file_path ):
20
+ im = Image .open (file_path )
21
+ green_channel = 1
22
+ green_data = im .getdata (green_channel )
23
+ datas = list (green_data )
24
+ datas_len = len (datas )
25
+ assert datas_len % 2 == 0
26
+ message = ""
27
+ for i in range (int (datas_len / 2 )):
28
+ index = 2 * i
29
+ left = datas [index ]
30
+ right = datas [index + 1 ]
31
+ abs_left_min_right = abs (left - right )
32
+ if abs_left_min_right != 42 :
33
+ message += chr (abs_left_min_right )
34
+ print (message )
35
+
36
+
37
+ if __name__ == "__main__" :
38
+ main ()
Original file line number Diff line number Diff line change 1
1
# pythonchallenge
2
2
Solve Problems in http://www.pythonchallenge.com
3
3
4
+ #### 28
5
+ result: http://www.pythonchallenge.com/pc/ring/guido.html
6
+ - use image.split() to split RGB channels
7
+ - im.bands() return number of im's channels
8
+ - ring means "green" if you visit "green.html" will get response "yes"
9
+ - whodunnit is an word means "who is the murderer"
10
+
11
+
4
12
#### 27
5
13
result: http://www.pythonchallenge.com/pc/ring/bell.html auth=(repeat, switch)
6
14
- author use python2 keyword, but there is some different with python3
You can’t perform that action at this time.
0 commit comments