Guest User

Untitled

a guest
Dec 3rd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. from PIL import Image
  2. from string import ascii_letters
  3. import ipdb
  4. i = Image.open("challenge.x.png")
  5.  
  6. ret = filter(lambda x: x in ascii_letters+" .,", i.tobytes())
  7.  
  8. lines = []
  9. for line in range(640):
  10.     c = 0
  11.     for col in range(640):
  12.         pix = i.getpixel((line, col))
  13.         if not pix == (0, 0, 0):
  14.             c += 1
  15.             preresult += ret.pop(0)
  16.     if c:
  17.         lines.append(c)
  18.  
  19. result = ret[:36]
  20. offset = 36
  21. halfs = lines[1:-2]
  22. for half in halfs:
  23.     result += ret[offset+half/2:offset+half]
  24.     offset += half
  25.  
  26. print result
Add Comment
Please, Sign In to add comment