Hi, I have this element {1, 1, 2, 3}, so i have an duplicate element. I want generate combinations and my result should be: {1} {2} {3} {1 1} {1 2} {1 3} {2 3} {1 1 2} {1 1 3} {1 2 3} {1 1 2 3}. The order of element isn't important, {1 1 2 3} == {2 3 1 1}, but i wan't a duplicate result set.

Member Avatar
Member Avatar
+0 forum 1

One way to find the shortest distance between a series of surface (x, y) points is to let Python module itertools find the non-repeating combinations of point pairs. Now you can apply the Pythagoras' theorem to find all the distances and the minimum distance.

Member Avatar
Member Avatar
+3 forum 2

Hi, I have a requirement where I need to generate the combinations of string based on some rules. For Eg: I have a string like: [x | y] z [A] Possible combinations are, z,ZA,xz,xyz,xzA,yzA The rules are, 1.[],| are symbols. 2.Any text inside [] is optional eg: [x] 3.| means “or” eg:;[x | y] – this means either “x” or “y”. Both cannot come together. 4.Any text outside [] is mandatory eg: z 5. <> Means range and can be ignored eg: <1-512> The text suffix to this operator must be treated as any other combination. Can we store these …

Member Avatar
Member Avatar
+0 forum 1

Hi all, I want to create all possible combinations of a full binary tree which must have exactly 4 leaf nodes and 3 internal nodes. I want to create it using recursion and tree must be simple binary tree not a binary search tree or BST. Kindly suggest algorithm to achieve this task. Thanks in advance.

Member Avatar
Member Avatar
+0 forum 4

Hi friends... I need to write a program in C which will print all the combinations of a string with non-repeating characters. Example: “Say” will have the following: s, a,y, sa, sy, as,sy, ys, ya, asy,sya,ysa and so on. The string length is not known. The string will be a command line argument to the program. For example if i Enter the string : say output i want to get is like this(below) s a y sa sy as ys ay ya sya ysa yas ays asy say please guys its urgent if any one have post it here

Member Avatar
Member Avatar
+0 forum 1

If you want to know the number of combinations of x things taken n at a time, you can use the Python module gmpy. The module gmpy is a C-coded Python extension module that supports fast multiple-precision arithmetic, very handy if x things reach a large number.

Member Avatar
+3 forum 0

I was reading this article [Click Here](http://maxburstein.com/blog/python-shortcuts-for-the-python-beginner/) http://maxburstein.com/blog/python-shortcuts-for-the-python-beginner/ In there was this example from itertools import combinations teams = ["Packers", "49ers", "Ravens", "Patriots"] for game in combinations(teams, 2): print game >>> ('Packers', '49ers') >>> ('Packers', 'Ravens') >>> ('Packers', 'Patriots') >>> ('49ers', 'Ravens') >>> ('49ers', 'Patriots') >>> ('Ravens', 'Patriots') So I thought I would play with it. very simply just used numbers to create a bigger list and a bigger tuple. >>> from itertools import combinations >>> numbers = [1,2,3,4,5,6,7,8,9,10] >>> for game in combinations(numbers, 6): print game When I received more combinations than I expected I wondered how many combinations …

Member Avatar
Member Avatar
+0 forum 6

my table has 2 fields, both are Keys. I save similar items in that table , like if 2 items are similar but have different Ids (in another table) I use this table to know that they are similar. so if items 1111, 1112 are the same and 1000,1002,1004 are the same, it'll looks like this- field1, field2 1111, 1112 1112, 1111 1000, 1002 1000, 1004 1002, 1000 1002, 1004 1004, 1002 1004, 1000 now I want to display the option to delete the connection between 2 items using a form, but I don't want the user to pick 1111,1112 …

Member Avatar
Member Avatar
+0 forum 3

My problem is let suppose my dataset is {A,B,C,D,E} and suppose my partition size is (2,3) Result would be (A,B) (C,D,E) (A,C) (B,D,E) (A,D) (C,B,E) (A,E) (B,C,D) (B,C) (A,D,E) (B,D) (A,C,E) (B,E) (A,C,D) (C,D) (A,B,E) (C,E) (A,B,D) (D,E) (A,B,C) I need to print all the possible combinations for the partition size provide...The partition size could be(1,4) also... Please help me out with the logic. Thanks

Member Avatar
Member Avatar
+0 forum 1

Hi All, I'm Trying to solve this puzzle for my script: Let's say we have 3 lists, A,B and C with the following elements 'A' = [5,3,1] 'B' = [6,5,2] 'C' = [2,0,-2] I want to go through all 27 combination sequentially, looking for a combination that is 'valid' AND has the highest sum. Let's say that A=3 B=2 and C = 2 is valid. Testing all 27 and computing the score (sum) will work, but is computationally too expensive for larger problems. I mean to say that the program should test the highest combination first: A=5 , B=6, C= …

Member Avatar
Member Avatar
+0 forum 8

As a companion article to my [URL="http://www.daniweb.com/code/snippet349081.html"]Permutation Generation[/URL], I now present Combination generation. This snippet will do a lazy generation of the combinations of a set of objects. Each combination has a grouping size (number of items in each combination). If you need a different grouping size, you'll have to create a new instance. As was done in the permutation class, you can request specific lexical combinations either by calling the method GetCombination or by using the index operator. [U]How to use[/U]: First you'll need an array of object. Call the Combination constructor passing the array and the grouping size. …

Member Avatar
Member Avatar
+2 forum 1

hello.. [COLOR="Red"]i need code for finding all possible combination of repetitive characters using recursion function.[/COLOR] actually the question i s "Imagine a robot sitting on upper left corner of NxN grid. the robot can only move in two direction "Right" and "Down". write a recursive function to find all possible paths that are there for robot? the above highlighted line is the logic i figured out but i am not able to convert it to C code. example: n=3. then there are total 6 possible paths. path1= RRDD path2= RDRD path3= RDDR path4= DDRR path5= DRDR path6= DRRD so, basicaly …

Member Avatar
Member Avatar
+0 forum 14

I'm not sure how to title the question I have so I can't be certain this hasn't been answered before. That said, following is a description of my programming question. I have a class R containing 2 integer elements, say X and Y. I then have two 24 element arrays named A and B where each element contains an instance of class R. I would like to iterate through the arrays to determine how to use R.Y to populate a third array C as follows: If R.Y at index i of A is larger than R.Y at index i of …

Member Avatar
Member Avatar
+0 forum 3

I have 10 words. How can I get all possible combinations of 5 words (n=10, k=5). The order does not matter. For example: "A", "B", "C", if k=2 (n=3 in this case), it would like AB, BC and AC. Maybe you know some usefull code or example. P.S. Sorry if I'm not right enough cause I don't know English very good.

Member Avatar
Member Avatar
+0 forum 2

Hi, Id like to generate a nine-digit combinations of 52 characters of alphabet (a..z and A..Z). My thought is: [LIST=1] [*]Generate nine-digit combinations of numbers from 0 to 51 [*]Use these combinations as indexes of [CODE]char[] alp={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};[/CODE] [/LIST] Iam sure its very easy.. Im learning Java for one month (once a week), sorry for my english (: Thank you very much for any idea

Member Avatar
Member Avatar
+0 forum 4

The End.