Jump to content

Textonyms: Difference between revisions

m
(→‎{{header|Ruby}}: use tr and group_by)
Line 2,748:
<lang ruby>
CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
NUMS = "22233344455566677778889999" * 2
dict = "unixdict.txt"
 
textonyms = File.open("unixdict.txt"dict){|f| f.map(&:chomp).group_by {|word| word.tr(CHARS, NUMS) } }
 
puts "There are #{File.readlines(dict).size} words in #{dict} which can be represented by the digit key mapping.
1,149

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.