doing a full permutation search and replace on a string

Posted by user73307 on Programmers See other posts from Programmers or by user73307
Published on 2012-11-21T22:41:59Z Indexed on 2012/11/21 23:11 UTC
Read the original article Hit count: 231

Filed under:
|

I'm writing an app that does something like a custom number (licence) place generator tool where if I ask for the plate "robin" it will suggest I try:

  • r0bin
  • rob1n
  • r0b1n

Are there any published algorithms which can do this? It has to be able to handle replacing single letters with multiples, e.g. m with rn and vise-versa and not fall over if it replaces an i with an l then comes to check the l and replaces it back to an i.

The list of what gets swapped with what is going to be user input but I'm not expecting a huge list, possibly 10 pairs at most.

I'll be implementing this in Ruby or Python but I should be able to convert code from any other language.

© Programmers or respective owner

Related posts about design-patterns

Related posts about search