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

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

Proposed solution123121321 for 9 symbols. Reasoning The first three symbols should be a permutation because otherwise we can trim the first symbol without losing any permutation. Without loss of ...

posted 1mo ago by Peter Taylor‭

Answer
#1: Initial revision by user avatar Peter Taylor‭ · 2026-08-04T08:05:23Z (about 1 month ago)
<details><summary>Proposed solution</summary><code>123121321</code> for 9 symbols.</details>

<details><summary>Reasoning</summary>

The first three symbols should be a permutation because otherwise we can trim the first symbol without losing any permutation. Without loss of generality we can start with `123`. Given a prefix, call a one-symbol continuation of it "good" if it contributes a new permutation.

The only good continuation of `123` is `1`, and the only good continuation of `1231` is `2`. There are no good continuations of `12312` because `123` is already contained in the string. So we have three permutations in five symbols. The other three permutations can similarly be done in five symbols, and by choosing to start at `2` we can overlap and save a symbol, giving nine symbols in total.

The result has only one three-symbol substring which doesn't contribute a necessary permutation: the central `121`. To improve on that would require starting with a permutation and making five good extensions, and we've already seen that this is impossible.

</details>