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 12

URI:
http://www.pythonchallenge.com/pc/return/evil.html
Log-in data:
Username: huge; password: file
Comment:
Possible Solution:
# Get the data from: http://www.pythonchallenge.com/pc/return/evil2.gfx

h = open("evil2.gfx", "rb")
data = h.read()
h.close()

new_data = [[], [], [], [], []]
n = 0

for byte in range(len(data) - 1):
    new_data[n].append(data[byte])
    n = 0 if n == 4 else n + 1

for n, elt in enumerate(new_data):
    h = open(str(n + 1), "wb")
    h.write("".join(elt))
    h.close()

(Download this source code.)

Code word for next challenge:
disproportional

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