Following the Huffman encoder posted here yesterday, here come the always useful Huffman decoder.
$/=$\;($l,$_)=unpack'sB*',<>;s/..//;r($&);$r=join'|',sort{$0{$b}cmp$0{ +$a}}keys %0;$_=substr$_,0,$l;s/$r/$0{$&}/g;sub r{@_=split//,pop;for$i(0,1){if($ +_[$i]){s /.{8}//s;$0{$p.$i}=pack'b8',$&}else{local$p=$p.$i;s/..//;r($&)}}}print
It is much shorter (229 bytes in Un*x), and as you will see, not much documented.
|
---|
Replies are listed 'Best First'. | |
---|---|
Huffman decoder SOLUTION
by BooK (Curate) on Feb 21, 2001 at 13:47 UTC | |
(tye)Re: Huffman decoder
by tye (Sage) on Feb 22, 2001 at 00:47 UTC | |
by demerphq (Chancellor) on Sep 16, 2001 at 17:03 UTC |
Back to
Obfuscated Code