Advertisement
austecliano

Encotel

Sep 25th, 2011
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.66 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. #Austecliano de Sรก Anacleto
  3. phones = String.new
  4. while str = gets
  5.   phone = Array.new
  6.   str.each_char do |c|
  7.     case c
  8.       when 'A','B','C'
  9.         phone << 2
  10.       when 'D','E','F'
  11.         phone << 3
  12.       when 'G','H','I'
  13.         phone << 4
  14.       when 'J','K','L'
  15.         phone << 5
  16.       when 'M','N','O'
  17.         phone << 6
  18.       when 'P','Q','R','S'
  19.         phone << 7
  20.       when 'T','U','V'
  21.         phone << 8
  22.       when 'W','X','Y','Z'
  23.         phone << 9
  24.       when '-'
  25.         phone << '-'
  26.       when '1'
  27.         phone << 1
  28.       when ' '
  29.         phone << ' '
  30.     end
  31.   end
  32.   phones << "#{phone}\n"
  33. end
  34. print phones
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement