Browse Source

call me maby solution

master
Stephen McQuay 8 years ago
commit
cf17dc32c9
2 changed files with 30 additions and 0 deletions
  1. +27
    -0
      call-me-maybe/call_me_maybe.py
  2. +3
    -0
      call-me-maybe/stdin1.txt

+ 27
- 0
call-me-maybe/call_me_maybe.py View File

@ -0,0 +1,27 @@
import sys
mebi_mapping = {
0: '0',
1: '1',
2: 'ABC',
3: 'DEF',
4: 'GHI',
5: 'JKL',
6: 'MNO',
7: 'PQRS',
8: 'TUV',
9: 'WXYZ',
}
lookup = {}
for k, v in mebi_mapping.iteritems():
for c in v:
lookup[c.lower()] = str(k)
lookup[str(k)] = str(k)
for line in sys.stdin:
number = ''
for c in line.strip():
number += lookup[c.lower()]
print number

+ 3
- 0
call-me-maybe/stdin1.txt View File

@ -0,0 +1,3 @@
5551234
GOPANDA
MebiPenny2012

Loading…
Cancel
Save