Skip to content

Instantly share code, notes, and snippets.

@tmarthal
Created March 20, 2014 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmarthal/9654497 to your computer and use it in GitHub Desktop.
Save tmarthal/9654497 to your computer and use it in GitHub Desktop.
digits2alpha = {'1':('1'),
'2':('a','b','c'),
'3':('d','e','f'),
'4':('g','h','i'),
'5':('j','k','l'),
'6':('m','n','o'),
'7':('p','q','r','s'),
'8':('t','u','v'),
'9':('w','x','y','z'),
'0':('0')}
def strings(digitstring):
if len(digitstring) < 2:
return digits2alpha[digitstring[0]];
else:
suffixes = strings(digitstring[1:])
vals = []
for prefix in digits2alpha[digitstring[0]]:
for suffix in suffixes:
vals.append(prefix+suffix)
return vals
if __name__ == "__main__":
z = strings('123')
print "Z is ", z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment