From: Russell Date: 2011-11-05T13:05:51+09:00 Subject: Re: Ruby Challenge --20cf307f3834d6e3b404b0f4ef1e Content-Type: text/plain; charset=ISO-8859-1 A solution like this is in the Pickaxe book as well. On Fri, Nov 4, 2011 at 11:53 PM, Intransition wrote: > Why does this sound like a school assignment? > > file = 'sample.txt' > freq = Hash.new{|h,k| h[k] = 0} > File.read(file).scan(/\w+/) do |w| > freq[w] += 1 > end > freq.each do |w,c| > puts "#{c} #{w}" > end > > Untested. > > --20cf307f3834d6e3b404b0f4ef1e--