shortening urls

@codinghorror posted "trying to formulate an algorithm for collapsing a long URL legibly." This sounded like a fun distraction from a semi-painful monday, and the first thing that occurred to me was using letter frequencies to prune urls down. I couldn't resist coding it up to see how well it would work.
 
First, here's the code:

 
So, for example:

 
>> url = "http://my.com/makethis/longish/url/shorter"
 >> host = "http://my.com/"
 >> shorten_url(url,host,7)
=> "http://my.com/makthis/longish/url/shorter"
 >> shorten_url(url,host,6)
=> "http://my.com/makhis/lngish/url/shortr"
 >> shorten_url(url,host,5)
=> "http://my.com/mkhis/lngsh/url/shorr"
 >> shorten_url(url,host,4)
=> "http://my.com/mkhs/lgsh/url/shrr"
 >> shorten_url(url,host,3)
=> "http://my.com/mks/lgh/url/srr"
 


not bad for a first cut