By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

combinations

P: 3
Does any one have a code for picking combinations of elements from different sets? For e.g.: If A={(1, 2), (3,4,5)}, I need a function that returns {(1, 3), (1, 4), (1, 5),(2, 3), (2, 4), (2, 5)}

Thanks
fitsumtk
Mar 9 '07 #1
Share this Question
Share on Google+
1 Reply


Ganon11
Expert 2.5K+
P: 3,652
You could very easily write this code. Think about each. each combination of 2 is 1 element from the 1st set and 1 element from the second. All you need is two nested for loops to iterate through the elements of each set and output (or otherwise process) the combination represented by the two indeces.
Mar 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.