-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path21.py
executable file
·23 lines (23 loc) · 1.03 KB
/
21.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#hint1: We used to play this game when we were kids
#hint2: When I had no idea what to do, I looked backwards.
#hint3: package.pack
import zlib,bz2
st=open('21_package.pack').read()
log=''
log_len=len(log)
while True:
try: #zlib
st=zlib.decompress(st)
log+=' '
except:
try: #bzip2
st=bz2.decompress(st)
log+='#'
except: #reverse
if log_len==len(log): break
st=st[::-1]
print log[log_len:]
log_len=len(log)
open('21_package.unpack','wb').write(st)
##Hint after the whole decompression process: look at your logs
##Originaly I kept a list with the number of zlib and bzip2 cycles run, expecting a banner(ish) run length encoding. I noticed that the sum of cycles needed to complete each direction was allways roughly the same. That is, before I had to reverse the string to start over, the sum of bzip+zip+bzip+... was more or less 73. And that meant that the output was meant to be directly graphical, so I sticked to simple string printig.