Puzzle with character order

503 Views Asked by At

Suppose I have 3 letters a, b, c and I want to find the minimum length of a string that uses all the double combinations of the aforementioned letters.

How should I do it or how are such problems called in order to search for them online?

Example:

The 3 letters a, b, c produce 9 double combinations:

  1. aa
  2. bb
  3. cc
  4. ab
  5. ac
  6. bc
  7. ba
  8. ca
  9. cb

What I want is a string that in its length will include all the combinations only one time or a minimum number of times, which in this case is only one time. For example the aabbcc includes the combinations: 1, 2, 3, 4, 6 like this:

  • 1: aa bbcc
  • 2: aa bb cc
  • 3: aabb cc
  • 4: a ab bcc
  • 6: aab bc c

The string that I want is actually this: aabbccacba which includes all the double combinations only once:

  • 1: aa bbccacba
  • 2: aa bb ccacba
  • 3: aabb cc acba
  • 4: a ab bccacba
  • 6: aab bc cacba
  • 8: aabbc ca cba
  • 5: aabbcc ac ba
  • 7: aabbccac ba
  • 9: aabbcca cb a

I am not concerned about the order that the combinations appear, so any similar string that includes the 9 combinations a minimum number of times would suffice. I only need that the double combinations to appear the minimum number of times.

The above concerns 3 letters and double combinations; let's call it a 3:2 problem. Imagine now that I want to have the flexibility to produce this string for 4:3, 7:2, 9:6 problems, etc...

Sincere apologies if this is not a question on mathematics.