On Jul 11, 2007, at 1:47 PM, James Edward Gray II wrote:

> A second version of my code.

One last tiny tweak.

> First, this is a tiny words.rb lib used by both the guesser and  
> test scripts:
>
> #!/usr/bin/env ruby -wKU
>
> WORDS_CASH_FILE = "words.cache"
>
> if File.exist? WORDS_CASH_FILE
>   WORDS = File.open(WORDS_CASH_FILE) { |file| Marshal.load(file) }
> else
>   WORDS = File.open( ARGV.find { |arg| arg =~ /\A[^-]/ } ||
>                      "/usr/share/dict/words" ) do |dict|
>     dict.inject(Hash.new) do |all, word|
>       all.update(word.delete("^A-Za-z").downcase => true)
>     end.keys

Changing that line to:

     end.keys.sort_by { |w| [w.length, w] }

helps me see where I'm at in the tests.

>   end
>   File.open(WORDS_CASH_FILE, "w") { |file| Marshal.dump(WORDS, file) }
> end
>
> __END__

James Edward Gray II