Jump to content
BrainDen.com - Brain Teasers

shuffling algorithm for letters in a word


Vincany
 Share

Recommended Posts

If there is a word , then will swapping 2 adjacent letters at the beginning of string will give me a new word (not necessarily a meaningful word) and then swapping the next 2 letters will give me a new word. After switching the last 2 letters , we go back to the beginning of the word and continue.
example: If the word is ABCCD , it becomes BACCD , then BCACD , BCCAD, BCCDA, then CBCDA and so on ..

Ignoring the swapping of the same two letters (like BCCDA) , will this algorithm give me all the words of all permutations ? I Tried for few number of letters and it works , but I want to know how to prove for any no. of letters. I have no idea how to prove it , it seems to work . By the way ,it is not a puzzle .

Link to comment
Share on other sites

It looks like you're taking the first letter and essentially rotating it through the different positions while the other letters remain in the same order. I noticed that all the possible permutations begin with two letters that were next to each other in the original sequence (or in the first and last spot). For example, I don't think you can get a sequence starting with AC. So this does not seem to hold up. 

  • Upvote 1
Link to comment
Share on other sites

  • 11 months later...

there is a way however to permute through all possibilities by swapping two letters.

ABC -> ACB -> BCA -> BAC -> CAB -> CBA

ABCD -> ABDC -> ACDB -.> ACBD -> ADBC -> ADCB ->

BDCA -> BDAC -> BADC -> BACD -> BCAD -> BCDA ->

CBDA -> CBAD -> CABD -> CADB -> CDAB -> CDBA->

DCBA -> DCAB -> DBAC -> DBCA -> DACB -> DABC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...