Jump to content

Shuffle -> Unshuffle A String...?

Recommended Posts

How do we know what a string was before it was shuffled?You can, of course, order the string alphabetically using some array methods. But if you shuffle a string like "house" there's no way the computer will know what the word was before it was shuffled.

Link to post
Share on other sites

Unshuffle this for me: "wisadfpovsavnkkslda"! (Hint: the answer is "vnkksldavsaisadwfpo".) :P (Technically, the point is that shuffle() is not bijective and thus not invertible, that is, there is no "unshuffle" function shuffle-1() such that shuffle-1(shuffle(x)) = x for all x. Of course, shuffle() isn't even deterministic.) If you mean, how can you arrange the characters of a string in alphabetical order, then you may want to try something involving sort(). ... as Ingolme said, and I didn't see :P.

Link to post
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.

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.

  • Create New...