to become more specific, here is an example:
> expand.grid(5, 5, c(1:4,6),c(1:4,6))
Var1 Var2 Var3 Var4
1 5 5 1 1
2 5 5 2 1
3 5 5 3 1
4 5 5 4 1
5 5 5 6 1
6 5 5 1 2
7 5 5 2 2
8 5 5 3 2
9 5 5 4 2
10 5 5 6 2
1...
In cases where order does matter, it's rather easy to generate the matrix of all possible outcomes. One way for doing this is using expand.grid as shown here.
What if it doesn't?
If I'm right, the number of possible combinations is (S+N-1)!/S!(N-1)!, where S is the number of dice, each with N sides numbered 1 through N. (It is differ...
I need to compute combinatorials (nCr) in Python but cannot find the function to do that in 'math', 'numyp' or 'stat' libraries. Something like a function of the type:
comb = calculate_combinations(n, r)
I need the number of possible combinations, not the actual combinations, so itertools.combinations does not interest me.
Finally, I...
Ok, so hopefully I can explain this in enough detail for somebody to be able to help me.. I am writing a program in C# that is supposed to take a text file and replace specific text, which happen to be names of files, and print a new text file for every single combination of the given filenames. The specific places to change the text of ...
I have a list of Groups that can vary in number, with Items in these groups that also vary in number. I've been racking my head over a way to get all possible combinations of 1 Item from every Group.
Bonus: I also need all combinations of not having every items from a group.
I've seen and done what was mentioned before, but that requ...
I want to pre-compute some values for each combination in a set of combinations. For example, when choosing 3 numbers from 0 to 12, I'll compute some value for each one:
>>> for n in choose(range(13), 3):
print n, foo(n)
(0, 1, 2) 78
(0, 1, 3) 4
(0, 1, 4) 64
(0, 1, 5) 33
(0, 1, 6) 20
(0, 1, 7) 64
(0, 1, 8) 13
(0, 1, 9) 24
(0, 1, 10...
I am not sure how to go about this in Python, if its even possible. What I need to do is create an array (or a matrix, or vector?) from 3 separate arrays. Each array as 4 elements as such, they return this:
Class1 = [1,2,3,4]
Class2 = [1,2,3,4]
Class3 = [1,2,3,4]
Now what I would like to do is return all possible combinations of thes...
For a game I'm making I have a situation where I have a list of numbers say [7, 4, 9, 1, 15, 2] (named A for this) and another list of numbers say [11, 18, 14, 8, 3] (named B) provided to me. The goal is to find all combinations of numbers in A that add up to a number in B. For example:
1 + 2 = 3
1 + 7 = 8
2 + 9 = 11
4 + 7 = 11
1...
I am trying to take a string and display the possible combinations of it (in PHP), but while saying in order of each word. For example: "how are you" would return (an array)
How are you
How are
are you
how
you
are
The code I have now displays all combinations but I am wanting it to keep them in order and not flip words. Any one have a...
Hey All,
I was just wondering if there's a way to generate many different combinations of numbers and letters, based off of just one number/letter? For example:
From just this one String:
234jk43fc7898cfg58
We could generate MANY different combos like:
HGYTD786Gjhghjg76fghf8
8976sgh8976
cv34905bv7
435bv4875bvg487bv
45b6467ne456n
4n5...
I suck at math, so I can't figure this out: how many combinations of k neighboring pixels are there in an image? Combinations of k pixels out of n * n total pixels in the image, but with the restriction that they must be neighbors, for each k from 2 to n * n. I need the sum for all values of k for a program that must take into account th...
Ok so i am really bored and have decided to make a lottery calculator type thing (yes i know, i am sad!)
Anyway, i was wondering if there was a java library method/class for working out permutations/combinations. I want to generate all possible number sets, that have 6 numbers from 1 - 49 with no repeats in them
If this isnt available...
Suppose you need to discover all possible permutations of 'n' distinct characters, say 'a', 'b', 'c'. Can you suggest an algorithm I can use to get this done? Generally speaking, how would you go about it?
...
I am looking for an algorithm for finding the simplest combination of integers from 0 to 5 (that is the one that consists of the fewest number of integers) that has not yet been used (the used combinations are in a list).
The order does matter and the combinations should be returned in a list.
For example, the list with the used number...
HI, I am working on a simple class to combine items of any type... this is for a poker game, this is how it looks:
public static List<List<T>> combinar<T>(List<T> items, int take)
{
List<List<T>> combs = new List<List<T>>();
var stuff = permutar<T>(items, take);
var all = from s in stuff
select new Tuple<Lis...
Given an array of strings
["the" "cat" "sat" "on" "the" "mat"]
I'm looking to get all combinations of items in sequence, from any starting position, e.g.
["the"]
["the" "cat"]
["the" "cat" "sat"]
...
["cat" "sat" "on" "the" "mat"]
["sat" "on" "the" "mat"]
["on" "the" "mat"]
...
["sat" "on"]
["sat" "on" "the"]
Combinations out of t...
I have list of possible words to make anagram of the given words. Each string of list is key to dictionary and has value of one or more words. Which is the best (fastest, pythonic) way to make all possible sentences in the order of the keys from the words in each list of the corresponding keys in the dictionary.
Lists have variable numbe...
Hello,
I have looked into every nook and simply cannot find the exit here, so if anybody can, please provide some insight.. (Mac OSX user - MS Excel 2008 (no VBA)
I have a list of content categories (string) from different sources (index) and my task is to create a list for a mapping document that will concatenate (or not) each row fro...
For example, I have an array
my @arr = qw(0 1 2 3 4);
How do I get the following combinations:
0
01
012
0123
01234
1
12
123
1234
2
23
234
3
34
4
If any, what's the name for this kind of combination (or permutation)?
Thanks like always!
...
I'm looking for the most efficient algorithm to randomly choose a set of n distinct integers, where all the integers are in some range [0..maxValue].
Constraints:
maxValue is larger than n, and possibly much larger
I don't care if the output list is sorted or not
all integers must be chosen with equal probability
My initial idea wa...