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 21

URI:
Log-in data:
Username: butter; password: fly
Comment:
My first grey hair I will name “level 21”. Hated it.
Possible Solution:
import zlib, bz2

h = open("package.pack") # Hides within the ZIP file we got at the
data = h.read()          # end of level 20.
h.close()

output = []

while True:
    if data.startswith("BZh"):
        data = bz2.decompress(data)
        output.append("#")
    elif data.startswith("x\x9c"):
        data = zlib.decompress(data)
        output.append(" ")
    elif data.endswith("\x9cx"):
        data = data[::-1]
        output.append("\n")
    else:
        break

print "".join(output)

(Download this source code.)

Code word for next challenge:
copper

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