13,458,920 members
See more:
how to shuffle the elements in an array using a key in such a way that no two adjacent elements should appear adjacently in shuffled array.From the shuffled array i need original array using only the same key.
Posted 11-Feb-13 17:29pm
Updated 11-Feb-13 18:35pm
v3
Sergey Alexandrovich Kryukov 11-Feb-13 23:52pm

What do you mean "with key"? Transposition is one of the simplest operations, just do it by definition.
—SA
Sergey Alexandrovich Kryukov 11-Feb-13 23:56pm

By the way, please stop posting "solutions" when your posts are not solution. All you can get is just abuse reports; and such reports can cause cancellation of your account. In case of heavy abuse, it happens.
—SA
Edo Tzumer 12-Feb-13 1:06am

Actually I think it's a nice question - it's not a simple transposition, making sure that two adjacent elements are now not adjacent.

Sorry, I don't understand what are your talking about, perhaps I don't know this term. A definition?
—SA
Edo Tzumer 12-Feb-13 1:30am

*If I understand manuthebos correctly*

Given an array: { 1, 2, 3, 4, 5}
you need to shuffle the array so that:
- 1 is not near 2
- 2 is not near 3 (and not 1 of course)
- ...

e.g. { 3, 1, 4, 2, 5} is a good shuffle

Is that called 'transposition'? Ah, in cycles... OK, thank you. And where is the "key" then?
—SA
Edo Tzumer 12-Feb-13 2:34am

The Key is the field you compare, in my example its just the numbers themselves.
Sergey Alexandrovich Kryukov 12-Feb-13 11:16am

OK, thanks...
—SA

Top Experts
Last 24hrsThis month
 ppolymorphe 101 Dave Kreskowiak 71 Raul Iloc 45 RickZeeland 45 Member 12810154 45
 OriginalGriff 6,070 Maciej Los 3,460 CPallini 2,347 Richard Deeming 2,220 ppolymorphe 2,189