From: Chad Fowler Date: 2004-11-06T23:25:14+09:00 Subject: Re: Succ distance between two strings On Sat, 6 Nov 2004 23:07:59 +0900, David A. Black wrote: > Hi -- > > > > On Sat, 6 Nov 2004, trans. (T. Onoma) wrote: > > > > > Is there an efficient way to calculate the "succ distance" between two strings > > (without iterating over each succession)? Examples: > > > > 'a'..'a' 0 > > 'a'..'b' 1 > > 'a'..'z' 25 > > 'a'..'aa' 26 > > 'a'...'aa'.to_a.size # would be one way For the first 3 examples you can also treat them as characters and do: ?a - ?a #=> 0 ?b - ?a #=> 1 ?z - ?a #=> 25 Not exactly what you want though. Chad Fowler http://chadfowler.com http://rubycentral.org http://rubygarden.org http://rubygems.rubyforge.org (over 20,000 gems served!)