hc=: 4 : 0 if. 1=#x do. y else. ((i{x),+/j{x) hc (i{y),: L.y NB. words are boxed not more than once w=. ,&.> y NB. standardized words assert. w -: ~.w NB. words are unique t=. 0 {:: x hc w NB. minimal weight binary tree ((< S: 0 t) i. w) { <@(1&=)@; S: 1 {:: t )