Skip to content

pandaant/huffmanrb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Huffmanrb

Implements a Huffman encoder/decoder in ruby.

Installation

$ git clone https://github.com/pandaant/huffmanrb.git
$ cd huffmanrb
$ rake all

Example usage:

Create input to encode. 50% a's, 33.33% b's, 16.66% c's.

$ ruby -e "puts %w[a a a b b c].map{ |c| [c]*10000 }.flatten.shuffle.join" > testinput

Compress input to file

$ huffrb < testinput > enc.testinput

Decompress encoded file to file

$ huffrb -d < enc.testinput > dec.testinput

Compare file sizes

$ du -h testinput enc.testinput

Possible output:

60K testinput
16K enc.testinput

Compare md5 checksums of original and the decoded file

$ md5sum testinput dec.testinput

Possible output:

7de2762f5bd59a7f95796d3fa43b23d1  testinput
7de2762f5bd59a7f95796d3fa43b23d1  dec.testinput

About

Implements a Huffman encoder/decoder in ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages