jeudi 26 février 2015

Suffle element such that, no element should come at its original index

I have a list of Object elements



SourceList ResultList (Expected)

Obj_A Obj_F

Obj_B Obj_C

Obj_C Obj_G

Obj_D Obj_B

Obj_E Obj_A

Obj_F Obj_B

Obj_G Obj_E


Suffle elements in SourceList such that, no element should come at its original index(in SourceList ) in ResultList .


For Example, in SourceList C is at index 2, so it must not come at index 2 in ResultList


So far, i have looked into Dearrangement Wiki , but algo gives me possible arrangements and i need just one.





Aucun commentaire:

Enregistrer un commentaire