--Apple-Mail-3--1057530766 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset -ASCII; format竟wed Begin forwarded message: > From: Hirotsugu Asari <asari / mac.com> > Date: May 13, 2007 6:58:20 PM CDT > To: submission / rubyquiz.com > Subject: Please Forward: Ruby Quiz Submission > --Apple-Mail-3--1057530766 Content-Transfer-Encoding: 7bit Content-Type: text/x-ruby-script; x-unix-mode44; x-mac-creatorT784D74; name ffman.rb Content-Disposition: attachment; filename ffman.rb #! /usr/bin/env ruby # Ruby Quiz #123 # Copyright 2007 Hirotsugu Asari class String def huffman_encode a elf.split(//) h } # hash of character occurences a.each { |c| h[c] [c].nil? ? 1 : h[c] + 1 } # puts h.inspect a .sort { |a,b| # sort the hash in descending order of the values b[1] <