-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge07.py
More file actions
executable file
·44 lines (39 loc) · 966 Bytes
/
challenge07.py
File metadata and controls
executable file
·44 lines (39 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# encoding: utf-8
"""
challenge06.py
http://www.pythonchallenge.com/pc/def/oxygen.html
image:
http://www.pythonchallenge.com/pc/def/oxygen.png
Started by whimsy on 2011-6-25.
Completed on... [incomplete]
Copyright (c) 2011 Will Crawford. All rights reserved.
"""
import sys
import os
import Image
def main():
try:
im = Image.open('challenge07.png')
except (IOError):
try:
im = Image.open('oxygen.png')
except:
print "Couldn't find image."
return 1
print "File found. \nBeginning processing...\n"
print "Size = " + str(im.size) + "px"
pix = im.load()
decoded = ''
for i in range(87):
j = i*7
decoded = decoded + chr(pix[j, 43][1])
print decoded
print "\nHardcoded answer: "
ans = [ 105, 110, 116, 101, 103, 114, 105, 116, 121 ]
answer = ''
for i in ans:
answer = answer + chr(i)
print answer
return 0
if __name__ == '__main__': main()