combinations

C# Function that generates strings according to input

Hi, I need a C# function that takes 2 strings as an input and return an array of all possible combinations of strings. private string[] FunctionName (string string1, string string2) { //code } The strings input will be in the following format: String1 eg -> basement String2 eg -> **a*f**a Now what I need is all combinations of ...

Getting the excluded elements for each of the combn(n,k) combinations

Suppose we have generated a matrix A where each column contains one of the combinations of n elements in groups of k. So, its dimensions will be k,choose(n,k). Such a matrix is produced giving the command combn(n,k). What I would like to get is another matrix B with dimensions (n-k),choose(n,k), where each column B[,j] will contain the e...

combinations algorithm

I want to make simple sorting algorithm. given the input "abcde", I would like the output below. could you tell me the algorithm for that? arr[0] = "a" arr[1] = "ab" arr[2] = "ac" arr[3] = "ad" arr[4] = "ae" arr[5] = "abc" arr[6] = "abd" arr[7] = "abe" ... arr[n] = "abcde" arr[n+1] = "b" arr[n+2] = "bc" arr[n+3] = "bd" arr[n+4] = "be"...

Combinations into pairs

I'm working on a directed network problem and trying to compute all valid paths between two points. I need a way to look at paths up to 30 "trips" (represented by an [origin, destination] pair) in length. The full route is then composed of a series of these pairs: route = [[start, city2], [city2, city3], [city3, city4], [city4, city5], ...

Find a set of common elements from a multi-dimensional array recursively

I have a multi-dimensional array: a=[[2,3,4],[1,3,4],[1,2],[1,2,3,4]] i've to compare all the 4 sub-arrays and get common elements.Next,take 3 subarrays at a time and get common elements.then take 2 sub arrays at a time and get common elements, in RUBY. ...

A Combinations of Items in Given List

Hello stackoverflow, I'm currently in Python land. This is what I need to do. I have already looked into the itertools library but it seems to only do permutations. I want to take an input list, like ['yahoo', 'wikipedia', 'freebase'] and generate every unique combination of one item with zero or more other items... ['yahoo', 'wikipe...

Algorithm for dynamic combinations

My code has a list called INPUTS, that contains a dynamic number of lists, let's call them A, B, C, .. N. These lists contain a dynamic number of Events I would like to call a function with each combination of Events. To illustrate with an example: INPUTS: A(0,1,2), B(0,1), C(0,1,2,3) I need to call my function this many times for ea...

adapting combination code for larger list

I have the following code to generate combinations of string for a small list and would like to adapt this for a large list of over 300 string words.Can anyone suggest how to alter this code or to use a different method. Public Class combinations Public Shared Sub main() Dim myAnimals As String = "cat dog horse ape hen mouse" ...

Counting through all binary numbers with equal 1's and 0's

I'm implementing a binary representation of an equal-side bi-partitioning algorithm and I'm wondering what the best way to iterate through all combinations of N bits that have equal (N/2) 1's and 0's. I'm trying to find the quickest way, not the easiest to code. Thanks. ...

Enumerating all combinations of lists of different types

Given two IEnumberables of different types, what is the best practice (considering readability and maintainability) for iterating over both lists to perform an action on all possible combinations? My initial solution was to use nested foreach loops, iterating over the first IEnumerable, and then within that loop, iterating over the sec...

C# algorithm for figuring out different possible combinations...

I have 10 boxes, each box can hold one item from a group/type of items, each 'group' type only fits in one of the 10 box types. The item pool can have n number of items. The groups have completely distinct items. Each item has a price, i want an algorithm that will generate all the different possibilities, so i can figure out different p...

Generating Mouse-Keyboard combination events in python

I want to be able to do a combination of keypresses and mouseclicks simultaneously, as in for example Control+LeftClick At the moment I am able to do Control and then a left click with the following code: import win32com, win32api, win32con def CopyBox( x, y): time.sleep(.2) wsh = win32com.client.Dispatch("WScript.Shell") w...

What category of combinatorial problems appear on the logic games section of the LSAT?

EDIT: See http://stackoverflow.com/questions/318888/solving-who-owns-the-zebra-programmatically for a similar class of problem There's a category of logic problem on the LSAT that goes like this: Seven consecutive time slots for a broadcast, numbered in chronological order I through 7, will be filled by six song tapes-G, H, L, O, ...

Python script to calculate aded combinations from a dictionary

I am trying to write a script that will take a dictionary of items, each containing properties of values from 0 - 10, and add the various elements to select which combination of items achieve the desired totals. I also need the script to do this, using only items that have the same "slot" in common. For example: item_list = { 'item_1...

Generate combinations by order and fixed length.

Suppose there is array main[] = [a,b,c,....z]; a[] = [a1,a2,a3,....] , b[] = [b1,b2,b3,....] and so on. So if we generate combination in main.length of ordered then it looks like ..... a1 b1 c1, a1 b1 c2, a1 b1 c3 ...... a1 b2 c1, a1 b3 c1, ..... a2 b1 c1, a3 b1 c1, ..... and total count will be a.length * b.length * c.length .........

What is the most effective and flexible way to generate combinations in TSQL?

What is the most effective and flexible way to generate combinations in TSQL? With 'Flexible', I mean you should be able to add easily combination rules. e.g.: to generate combinatories of 'n' elements, sorting, remove duplicates, get combinatories where each prize belongs to a different lottery, etc. For example, Having a set of number...

Libraries C/C++ for ordered combinations generation and ranking/unranking ?

Hello, I'm looking for a library which could rank/unrank ordered combinations (ranking means from a combination it give you which nth combinations it is from a gray code or lexicographic or some other algorithm, unranking is the reversing process). I look for a library doing many algorithmes like gray code or lexicographic, rev-lexico...

enumerate all combinations in c++

Possible Duplicate: Howto create combinations of several vectors without hardcoding loops in C++? My question is similar to this combinations question but in my case I have N (N > 4) small sets (1-2 items per set for now might go to 3 maybe 4) and want to generate each combination of one item from each set. The current soluti...

How to map combinations of things to a relational database?

I have a table whose records represent certain objects. For the sake of simplicity I am going to assume that the table only has one column, and that is the unique ObjectId. Now I need a way to store combinations of objects from that table. The combinations have to be unique, but can be of arbitrary length. For example, if I have the Obje...

Is there an R function to get the number of permutations of n objects take k P(n,k)?

..or do I have to give P.nk <- factorial(n) / factorial(n-k) or P.nk <- choose(n,k) * factorial(k) Thank you. ...