On Fri, Apr 19, 2013 at 1:36 PM, Joel Pearson <lists / ruby-forum.com> wrote:
> 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(' ')

Curious how you'd handle contractions :)