-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7.py
44 lines (34 loc) · 1.23 KB
/
7.py
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
44
#!/usr/bin/python
# Problem - http://www.pythonchallenge.com/pc/def/oxygen.html
# Thought process -
# 1. There is a grey scale gradient in the middle of the image
# 2. Run a loop over length and read the middle pixel value in the image
# 3. 7 represent that every 7th value must be read as values are repeating itself
# 4. convert the values to its ascii value, we get
# 5. smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]pe_
# 6. ignore the last 3 characters as they are gitter
# 7. take the dictionary and again convert it in ascii values
# 8. We get integrity
# Solution - http://www.pythonchallenge.com/pc/def/integrity.html
import re
import requests
from PIL import Image
from StringIO import StringIO
# http://www.pythonchallenge.com/pc/def/oxygen.png
req = requests.get('http://www.pythonchallenge.com/pc/def/oxygen.png')
png = Image.open(StringIO(req.content))
pix = png.load()
x = 0
y = png.size[1] / 2
ans = ""
while(x < png.size[0]):
ans += str(chr(pix[x,y][0]))
x += 7
#print(ans)
# smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]pe_
foo = [105, 110, 116, 101, 103, 114, 105, 116, 121]
bar = ""
for i in foo:
bar += str(chr(i))
print(bar)
# integrity