--Apple-Mail-1--443850543 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset -ASCII; formatðïwed Begin forwarded message: > From: Ezwan Aizat Bin Abdullah Faiz <aizat.faiz / gmail.com> > Date: October 8, 2006 11:34:06 PM CDT > To: submission / rubyquiz.com > Subject: Please Forward: Ruby Quiz Submission > > My first submission to Ruby Quiz :), though its not as short as the > others. > > The line I get is: > uncompress wait qhold mkfifo xargs jobs zcat type val > > I have a feeling it can be better though. > > Regards, > Aizat > > -- > aizat faiz: sleep to the power of z. -_-;;^zzz > strange symphonies - http://aizatto.com/ > > Malaysia Free and Open Source Group: > * http://foss.org.my --Apple-Mail-1--443850543 Content-Transfer-Encoding: 7bit Content-Type: application/x-ruby; x-unix-mode66; name iz97.rb Content-Disposition: attachment; filename iz97.rb #!/usr/bin/ruby words w{admin alias ar asa at awk basename batch bc bg c99 cal cat cd cflow chgrp chmod chown cksum cmp comm command compress cp crontab csplit ctags cut cxref date dd delta df diff dirname du echo ed env ex expand expr false fc fg file find fold fort77 fuser gencat get getconf getopts grep hash head iconv id ipcrm ipcs jobs join kill lex link ln locale localedef logger logname lp ls m4 mailx make man mesg mkdir mkfifo more mv newgrp nice nl nm nohup od paste patch pathchk pax pr printf prs ps pwd qalter qdel qhold qmove qmsg qrerun qrls qselect qsig qstat qsub read renice rm rmdel rmdir sact sccs sed sh sleep sort split strings strip stty tabs tail talk tee test time touch tput tr true tsort tty type ulimit umask unalias uname uncompress unexpand unget uniq unlink uucp uudecode uuencode uustat uux val vi wait wc what who write xargs yacc zcat } line " flags } letters } ('a'..'z').to_a.each do |char| char har.to_sym flags[char] alse letters[char] ] end words.each do |word| word.each_byte do |char| # removes words with numbers in them next if (char < 'a'[0] || char > 'z'[0]) char har.chr.to_sym tmp etters[char] tmp << word end end class String def to_a chars ] self.each_byte do |char| chars << char.chr end chars end end def suitability(value, flags) value alue.to_a amount chars alue.uniq chars.each do |char| char har.to_sym amount + if flags[char] false end amount end while flags.has_value? false # Remove empty elements from the list letters.delete_if { |key, value| value.empty? } # Determine the most suitable word for each element letters.each_key do |key| # Shifts the most suitable word to the start of the array letters[key].sort! do |x, y| suitability(y, flags) <