cyfer65 Posted December 7, 2011 Share Posted December 7, 2011 I know there is a PHP function to shuffle a string.But is there a function to unshuffle that string..?If not, how could accomplish a shuffle -> unshuffle string function..? Link to comment Share on other sites More sharing options...
Ingolme Posted December 7, 2011 Share Posted December 7, 2011 What exactly does an "unshuffle" function do? Link to comment Share on other sites More sharing options...
cyfer65 Posted December 7, 2011 Author Share Posted December 7, 2011 unshuffles a shuffled string derp!abc123 -> c3a1b2c3a1b2 -> abc123 Link to comment Share on other sites More sharing options...
justsomeguy Posted December 7, 2011 Share Posted December 7, 2011 There's no way to know what the string was before it was shuffled, it could be any combination. You can save those pairs in a database if you want to look them up. Link to comment Share on other sites More sharing options...
Ingolme Posted December 8, 2011 Share Posted December 8, 2011 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 More sharing options...
Synook Posted December 8, 2011 Share Posted December 8, 2011 Unshuffle this for me: "wisadfpovsavnkkslda"! (Hint: the answer is "vnkksldavsaisadwfpo".) (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 . Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.