From: Hugh Sasse Date: 2005-11-01T19:55:56+09:00 Subject: Re: TumbleDRYer (#53) - my solution On Tue, 1 Nov 2005, Dale Martenson wrote: > For readability, I left the binary encoding as strings rather than > converting them to integers. This could easily be accomplished by > prefixing the encoding with '0b' and using String::to_i(0) to do the > conversion to an integer. This would be important if you wished to use > this as a compression technique. Yes, you could assemble the whole lot and use pack for that. It was a nice approach. I think the problem with coding methods like the one I used is getting the code words mapped to meaningful names so one can still read the code. That would be beyond the scope of a quiz though, I expect, because it would involve advanced natural language programming to come up with the short concept names for the code words. I liked the Huffman coder. I have usually ducked out of using Huffman coders because of managing all the tree rearrangement and construction, but your code is very clear. I've usually used Shannon-Fano code for such things in the past, though it is a little less efficient (in terms of the codes it produces), because you only sort the list of code words once. Since the quiz is about reducing repetition in code: I think you could probably use a superclass for the Internal and Leaf nodes to hold common instance vars. Thank you. I wonder if anyone else will have a go? Hugh