I generally don't approve of doing people's homework for them, but this 
one interests me.
I'm not very experienced with code so I bet there's an easier way to do 
this... anyway, here's my attempt:

puts gets.chomp.split.map { |s|
  letters = s.gsub(/\W/,'')
  if [0,1,2].include? letters.length || s !~ /[A-Z]/i
    s
  else
    s[/^[^A-Z]*[A-Z]/i] + ( letters.length - 2 ).to_s + 
s[/[A-Z][^A-Z]*$/i]
  end
}.join(' ')

-- 
Posted via http://www.ruby-forum.com/.