35 lines
475 B
CoffeeScript
35 lines
475 B
CoffeeScript
> coffee huffman.coffee
|
|
---- this is an example for huffman encoding
|
|
000 : n (4)
|
|
0010 : s (2)
|
|
0011 : m (2)
|
|
0100 : o (2)
|
|
01010: t (1)
|
|
01011: x (1)
|
|
01100: p (1)
|
|
01101: l (1)
|
|
01110: r (1)
|
|
01111: u (1)
|
|
10000: c (1)
|
|
10001: d (1)
|
|
1001 : i (3)
|
|
101 : (6)
|
|
1100 : a (3)
|
|
1101 : e (3)
|
|
1110 : f (3)
|
|
11110: g (1)
|
|
11111: h (2)
|
|
|
|
---- abcd
|
|
00 : a (1)
|
|
01 : b (1)
|
|
10 : c (1)
|
|
11 : d (1)
|
|
|
|
---- abbccccddddddddeeeeeeeee
|
|
0 : e (9)
|
|
1000 : a (1)
|
|
1001 : b (2)
|
|
101 : c (4)
|
|
11 : d (8)
|