Blowing Down The House (solution)

by David Turner with suggestions from Andrew Lin

The block of data is Huffman-encoded with a 3-ary tree generated from the provided frequency table. When three items are to be encoded at the same level of the tree, the least-frequent gets a zero and the most-frequent gets a 2.

The resulting Huffman code is:

[space]10
A010
B122
C221
D111
E00
F121
G011
H200
I012
J1102
K2021
L212
M210
N220
O222
P120
Q11000
R02
S211
T201
U112
V1101
W2022
X11001
Y2020
Z11002

The decoded data reads:

REENCODE THIS STRING OPTIMALLY THEN DECODE USING THE ORIGINAL CODE YOUR ANSWER WILL APPEAR FOLLOWED BY GIBBERISH WHEN OPTIMIZING INCLUDE THE FOLLOWING PADDING BOXTOP CLAMPS CLAY DAN DRILL DUMP DUNK FAMILY FEVER FLAY FLUB GRAMMAR GRAMPS GROW GUNK HIGHWAY HIM HUMPS HUNT JACK JAY JOKER JOVIAL JUMPER JUNK KISMET LOUSE MAJOR MAST MAZE NEON NEST NOSE PLANTS PLOTS PUSHED QUICK RAFFLE ROAD SLIM SLOT SO STOOP STUMPED SWANK THEOREM THINK THUMP UNDERWHELM VIKING VIXEN WARP WHAMMY WHIG WHISKEY ZACK

This has the following frequencies:

[space]78
A28
B5
C9
D16
E34
F8
G14
H19
I29
J7
K12
L25
M22
N26
O27
P18
Q1
R21
S23
T20
U17
V4
W13
X2
Y10
Z3

The optimal Huffman code is then:

[space]21
A222
B1011
C2012
D102
E01
F2011
G100
H112
I00
J2010
K021
L202
M122
N220
O221
P111
Q10120
R121
S200
T120
U110
V1010
W022
X10121
Y020
Z10122

Encoding with the optimal tree and then decoding with the original generates the answer, FABRIC, followed by garbage.

Ben Bitdiddle
Ben Bitdiddle