Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1567915

Browse files
authoredOct 7, 2024··
Create Deflate.py
1 parent dba8eec commit 1567915

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎compression/Deflate.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import zlib
2+
3+
# Data to compress
4+
data = b"Hello, DEFLATE! This is an example of data compression using the DEFLATE algorithm."
5+
6+
# Compress the data using DEFLATE
7+
compressed_data = zlib.compress(data)
8+
9+
# Decompress the data
10+
decompressed_data = zlib.decompress(compressed_data)
11+
12+
# Output results
13+
print(f"Original Data: {data}")
14+
print(f"Compressed Data: {compressed_data}")
15+
print(f"Decompressed Data: {decompressed_data}")
16+
17+
# Verify the decompressed data matches the original
18+
assert data == decompressed_data, "Decompressed data does not match the original data!"

0 commit comments

Comments
 (0)
Please sign in to comment.