RosettaCodeData/Task/Ordered-words/Ruby/ordered-words-2.rb

3 lines
148 B
Ruby

words = IO.foreach('unixdict.txt').map(&:chomp).select {|word| word.chars.sort.join == word}
puts words.group_by(&:size).sort_by(&:first).last.last