3 # $Id: wordfreq.ruby,v 1.2 2004-07-03 05:36:11 bfulgham Exp $
4 # http://shootout.alioth.debian.org/
8 data = (STDIN.read(4095) or break) << (STDIN.gets
|| "")
9 for word
in data.downcase
.tr_s('^A-Za-z',' ').split(' ')
16 freq
.each
{|w
,c
| lines
<< sprintf("%7d %s\n", c
, w
) }
17 print lines
.sort
.reverse