Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Incubator Q&A

Welcome to the staging ground for new communities! Each proposal has a description in the "Descriptions" category and a body of questions and answers in "Incubator Q&A". You can ask questions (and get answers, we hope!) right away, and start new proposals.

Are you here to participate in a specific proposal? Click on the proposal tag (with the dark outline) to see only posts about that proposal and not all of the others that are in progress. Tags are at the bottom of each post.

Post History

66%
+2 −0
Incubator Q&A Find the shortest possible string containing all permutations of 1, 2, 3

There are 6 permutations of the numbers 1, 2, 3. They are: 123 132 213 231 312 321 The goal is to make a string (as short as possible) using the digits 1, 2 and 3 so that each of the abov...

1 answer  ·  posted 1mo ago by will.octagon.gibson‭  ·  last activity 1mo ago by Peter Taylor‭

Question puzzles mathematics
#1: Initial revision by user avatar will.octagon.gibson‭ · 2026-08-04T01:26:56Z (about 1 month ago)
Find the shortest possible string containing all permutations of 1, 2, 3
There are 6 [permutations](https://en.wikipedia.org/wiki/Permutation) of the numbers 1, 2, 3.

They are:

```text
123
132
213
231
312
321
```

The goal is to make a string (as short as possible) using the digits 1, 2 and 3 so that each of the above 6 permutations occur at least once in consecutive positions in the string.

The sample string below contains all 6 permutations.  The string is 12 digits long but there are shorter strings that contain all 6 permutations.

As examples, the permutation 213 occurs in the positions marked AAA and the permutation 123 occurs in the positions marked BBB.

```text
  AAA    BBB
132132323123
```

What is the shortest string that satisfies the above conditions?

---

I know what the shortest string length is.

If you post a correct string with that shortest possible length, I plan to upvote your answer.

If you also give a proof that your answer is minimal which I find easy to understand, I plan to mark your answer as **Works for me.**