Jump to content

Shuffle -> Unshuffle A String...?


cyfer65

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 comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...