Hi -- On Thu, 10 Feb 2005, Bertram Scharpf wrote: > Hi, > > Am Donnerstag, 10. Feb 2005, 09:26:39 +0900 schrieb Bill Guindon: >> On Thu, 10 Feb 2005 09:14:14 +0900, Jordi Bunster <jordi / bunster.org> wrote: >>> Does anyone have one of those algorithms that convert a phone number to >>> a word, using /usr/share/dict/words, for example? >> >> Sounds like it would make a good ruby quiz, and Friday's coming. > > words = %w(zero one two ...) > number.scan( /[0-9]/).map { |x| words[ x.to_i] }.join ' ' I don't think that's what Jordi meant. I think it's more like: convert the numbers to their letter equivalents (2 => a,b,c; 3 => d,e,f; etc. [in the U.S.]), and then see what words you can spell. Just for fun, though, here's another way to do yours: require 'scanf' number.scanf("%1d") {|n,| words[n] }.join(" ") David -- David A. Black dblack / wobblini.net