Skip to content

Commit eab7ce1

Browse files
21
1 parent cd19b5a commit eab7ce1

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

21.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import zlib
2+
import bz2
3+
4+
5+
def main():
6+
first_step()
7+
8+
9+
def first_step():
10+
file = open("game/package.pack", "rb")
11+
bs = file.read()
12+
result = ""
13+
while True:
14+
if bs.startswith(b"x\x9c"):
15+
bs = zlib.decompress(bs)
16+
result += " "
17+
elif bs.startswith(b"BZ"):
18+
bs = bz2.decompress(bs)
19+
result += "#"
20+
elif bs.endswith(b"\x9cx"):
21+
bs = bs[::-1]
22+
result += "\n"
23+
else:
24+
break
25+
print(result)
26+
27+
28+
if __name__ == "__main__":
29+
main()

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# pythonchallenge
22
Solve Problems in http://www.pythonchallenge.com
33

4+
#### 21
5+
result: http://www.pythonchallenge.com/pc/hex/copper.html
6+
```python
7+
import zlib
8+
import bz2
9+
```
10+
- Here is a [List of file signatures](https://en.wikipedia.org/wiki/List_of_file_signatures)
11+
12+
413
#### 20
514
result: password is redavni
615
```python
@@ -23,9 +32,9 @@ import base64
2332
import wave
2433
```
2534
- use base64 to decode these codes
26-
- use wave to reand and write frame
35+
- use wave to read and write frame
2736
- the sea is yellow the land is blue,which is out of order
28-
- if you email to leopold with “sorry”, you will find a surprise
37+
- if you email to leopold with “sorry” as subject, you will get a surprise
2938

3039

3140
#### 18

0 commit comments

Comments
 (0)