+ 31

[ASSIGNMENT] COMPRESSION 📂📁🔤

Challenge #6 It's time to compress strings. The challenge is to create a code which compresses a string using any algorithm of your choice but without using any built in compression utilities (like zlib). The output can be in the form of string, integers or bytes. The code should also be able to decompress the compressed string. Good luck 👍 Happy Coding. At least try to participate 😉.

17th Jan 2018, 10:56 AM
Swapnil Srivastava
Swapnil Srivastava - avatar
18 Answers
+ 3
BitCompressor. Nested one liners. https://code.sololearn.com/cND813iJ5Ang/?ref=app
18th Jan 2018, 7:17 AM
VcC
VcC - avatar
+ 18
@Kartik Krishnan Your code does does not seem to compress a string. It seems to encrypt.
17th Jan 2018, 2:48 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 13
@Swapnil Srivastava Congratulations !! 👍👏 for Quiz Approved !! 🤗
18th Jan 2018, 3:52 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 9
https://code.sololearn.com/cTzAfvq28D5u/#py Compressed string with an efficiency up to 8-10 %. Update 1: efficiency upgraded up to 14-17% Update 2: up to 21-22% Update 3: up to 30%✨😍 Update 4: I have compressed (with a little bit zlib cheating) the String to 0.42155 of its original length 57% (sometimes up to 62%!!!) efficiency! Without zlib it's 25-35% Works on every ASCII language, even pretty efficient on a random string.
18th Jan 2018, 12:55 PM
Serge Gerodes
Serge Gerodes - avatar
+ 7
I already made this, kind of. it's a poor compression that turns a world the user creates which is 16*16*16 into a hash (string) of 459 characters, and it takes any hash and turns it back into a world not exactly what you mean though, I'll delete the post if you find it too off topic https://code.sololearn.com/Wf4qVq5lj7V7/?ref=app
17th Jan 2018, 12:11 PM
wout werkman
wout werkman - avatar
+ 5
I made a random compressor. Hope you like it! If you don't give input, it will take a default string. https://code.sololearn.com/cHrE7wZ3I9D2/?ref=app
17th Jan 2018, 2:00 PM
Kartik
Kartik - avatar
+ 5
Can this be called string compression? This removes repetitive characters. I am not sure if it suits your challenge but I hope it fulfills few requirements. (Sorry No decompression) https://code.sololearn.com/c8MpEO7Pb6b0/?ref=app
18th Jan 2018, 7:08 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 5
@Serge Gerodes zlib is not allowed. no build in compression utilities =P
19th Jan 2018, 8:09 AM
João Duarte
João Duarte - avatar
+ 4
@VcC I tried to use your code on the string Lo`OipsuOdolU$iFa1tQ8n(c*t<}RpS4ngI+tjMa[~aCakarcu}k*yuCfau4buC3tY4!jDuiCv!Tb3uOWaFxI+F*mpUQid2a4+@Czo 8n(c*t<jNunk8n(c*t<J!Tb3uOa+q;tj/SedJ^aeJolutpaFWosjNuy>lo`Ol[%sQrutruOid RgnS@OHQrutruOidBSijV!Tb3uOWaFan*,Ig!taCidJe+F-Qfa4+@Cfa4+@CnuyajPhXeyuCvwJ!Tb3uOt<pSjPhXeyuC{iCp3 it did not worked
18th Jan 2018, 10:20 AM
Serge Gerodes
Serge Gerodes - avatar
+ 4
@serge You need to define the divtionnary. It works well when you are using only some of the ascii code (like alphanum only)
18th Jan 2018, 10:22 AM
VcC
VcC - avatar
+ 4
@VcC I wanted to combine out two algorithms to gain more power. My is using all printable ascii‘s exclude special characters like „\“. But its not possible because yours is using only a subset of my alphabet...
18th Jan 2018, 10:33 AM
Serge Gerodes
Serge Gerodes - avatar
+ 4
@gerodes you can use any alphabet but compression will be log(len(alpha))/log(256)
18th Jan 2018, 10:40 AM
VcC
VcC - avatar
+ 3
@Swapnil Shrivastava My bad. I will try to make a code for compression.
17th Jan 2018, 2:50 PM
Kartik
Kartik - avatar
+ 3
In my defense I would like to say: "if it looks stupid but it works it ain't stupid" so... here's my text compressor https://code.sololearn.com/cdWrn6FeAO88/?ref=app
18th Jan 2018, 1:25 PM
Stoyan Todorov
Stoyan Todorov - avatar
+ 3
edit: decompression works now compression ratio of 84%, not really good but it works https://code.sololearn.com/cUy2RLE2Uk9z/#rb
19th Jan 2018, 1:13 PM
bedawang
bedawang - avatar
+ 2
@Swapnil Shrivastava Is my code good enough for your challenge?
17th Jan 2018, 2:47 PM
Kartik
Kartik - avatar
+ 1
Hi have written code which is used to compress the string . My code counts the the repetitive characters and adds the numeric value . For Example Input: aaabccdee Output:a3bc2de2 I have not taken care for decompression https://code.sololearn.com/cLjCoTD6qe13/#cs
19th Jan 2018, 4:17 PM
Srivani Chinta
Srivani Chinta - avatar