Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- #Austecliano de Sá Anacleto
- phones = String.new
- while str = gets
- phone = Array.new
- str.each_char do |c|
- case c
- when 'A','B','C'
- phone << 2
- when 'D','E','F'
- phone << 3
- when 'G','H','I'
- phone << 4
- when 'J','K','L'
- phone << 5
- when 'M','N','O'
- phone << 6
- when 'P','Q','R','S'
- phone << 7
- when 'T','U','V'
- phone << 8
- when 'W','X','Y','Z'
- phone << 9
- when '-'
- phone << '-'
- when '1'
- phone << 1
- when ' '
- phone << ' '
- end
- end
- phones << "#{phone}\n"
- end
- print phones
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement