Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with random combination from lists

Status
Not open for further replies.
Jan 24, 2010
1
SE
hey! i need help with this.

lets say i have 2 lists [A,B,C] nd [1,2,3]

how can i generate all the 9 unique combinations in a random way?

that is--as an example


once B1 is generated it shouldnt generate B1 again..and after generating all 9 combinations randomly it will stop.
 
You count the number of pairs you can get.
You loop on the number of pairs already done.
At each step you repeat a random choice of elements of L1 and L2 until the pair [C1, C2] is not already found.
(sorry for my bad English).

Antother possibility : you get all the combinations possibles and then shuffle the list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top