quick implementation of the package-merge algorithm for limited-length codes