0

Let's say I have a three character string "ABC". I want to generate all permutations of that string where a single letter can be replaced with his lower-case equivalent. For example, "aBC", "abC", "abc", "AbC", "Abc", etc. In other words, given a regexp like [Aa][Bb][Cc] generate every string that can be matched by it.

1 Answer 1

2

The problem can be trivially reduced to generating all binary sequences of length n. This has been previously addressed, for example in Fastest way to generate all binary strings of size n into a boolean array? and all permutations of a binary sequence x bits long.

Sign up to request clarification or add additional context in comments.

8 Comments

Not exactly, you can use either "A" or "a" - not both (in the same permutation item)
@alfasin: Not sure I follow. Each binary digit corresponds to a letter. 0 is lowercase, 1 is uppercase. 000 stands for abc, 001 for abC, 010 for aBc and so on.
if you use lowercase "a" you MUST use the capitals: "B" and "C" in this same permutation. At least according to his definition: "where a single letter can be replaced..."
@alfasin: That's what he says, but I doubt he means it. Look at the examples: they repeatedly violate the constraint.
I am using upper-/lower-case only as an example: the transformation on the character is table-driven.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.