Small things amuse ...
February 9, 2010, 4:25 pm
Recursion is fun. Just sayin...
mappings = { 'o':['1','2'], 'k':['d','l','w'] }
def printVariants (substring):
print (substring)
for i in range(0, len(substring)):
if mappings.has_key (substring[i]):
for mapped in mappings[substring[i]]:
newSubstring = substring[:i] + mapped + substring[i + 1:]
printVariants (newSubstring)
printVariants ("fook")
Permalink - Tags: Development