Solutions for the Python Challenge

Show possible solutions for: All levels; level: previous, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, next

Possible solution for level 16

URI:
http://www.pythonchallenge.com/pc/return/mozart.html
Log-in data:
Username: huge; password: file
Comment:
Possible Solution:
import Image, ImageChops

# Download the image from: http://www.pythonchallenge.com/pc/return/mozart.gif

image = Image.open("mozart.gif")
magic = chr(195)

for y in range(image.size[1]):
    box = 0, y, image.size[0], y + 1
    row = image.crop(box)
    bytes = row.tostring()
    i = bytes.index(magic)
    row = ImageChops.offset(row, -i)
    image.paste(row, box)
    
image.save("new.gif")

(Download this source code.)

Code word for next challenge:
romance

By Holger Thölking, May 29th, 2007.