I have written code to implement an algorithm I found on string permutations. What I have is an arraylist of words ( up to 200) and I need to permutate the list in levels of 5. Basically group the string words in fives and permutated them. What I have takes the first 5 words generates the permutations and ignores the rest of the arraylis...
I could do this using loops, but is there a way to take two IEnumerables, enumerate through all possible permutations and select an object that contains the permutation? I feel like this 'should' be possible but am not really sure what operators to use.
Thanks
James
...
I'm interested making an implementation of the 14-15 puzzle:
I'm creating an array with the values 0 - 15 in increasing order:
S = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
Now, what I want to do is shuffle them to create a new instance of the puzzle. However, I know that if I create a board with an "odd permutation" ...
I know you can generate all permutations from a list, using glob or Algorithm::Permute for example - but how do you generate all possible permutations from a regular expression?
I want to do like:
@perms = permute( "/\s[A-Z][0-9][0-9]/" );
sub permute( $regex ) {
# code - put all permutations of above regex in a list
return @l...
I have a graph (with nodes and edges) containing symmetry and a group of permutations to label the nodes so no edges are changed (automorphisms). Now I would like to determine for which nodes a permutation exchanges two equivalent (i.e. nodes with the same color or symmetry class) neighboring nodes.
When the nodes with equivalent neighb...
I am writing a program that takes in an ArrayList and I need to calculate all possible permutations starting with a list of zeroes, up to the value in the corresponding input list.
Does anyone know how to iteratively calculate these values?
For example, given [ 1 2 ] as input, it should find and store the following lists:
[0 0],
[1 0]...
Is there some equivalent library or function that will give me the next combination of a set of values like next_permutation in does for me?
...
Hi,
I have a list of numbers for input, e.g.
671.00
1,636.00
436.00
9,224.00
and I want to generate all possible sums with a way to id it for output, e.g.:
671.00 + 1,636.00 = 2,307.00
671.00 + 436.00 = 1,107.00
671.00 + 9,224.00 = 9,224.00
671.00 + 1,636.00 + 436.00 = 2,743.00
...
and I would like to do it in Python
My current...
Say I have a list of n elements, I know there are n! possible ways to order these elements. What is an algorithm to generate all possible orderings of this list? Example, I have list [a, b, c]. The algorithm would return [[a, b, c], [a, c, b,], [b, a, c], [b, c, a], [c, a, b], [c, b, a]].
I'm reading this here
http://en.wikipedia.org/wi...
Is there a better way to do this:
perms = product(range(1,7),range(1,7),range(1,7))
so that I can choose how many ranges I use?
I want it to be equivalent to this, but scalable.
def dice(num)
if num == 1:
perms = ((i,) for i in range(1,7))
elif num == 2:
perms = product(range(1,7),range(1,7))
elif num == 3...
Hi everyone.
I'm study recommendation engines, and I went through the paper that defines how Google News generates recommendations to users for news items which might be of their interest, based on collaborative filtering.
One interesting technique that they mention is Minhashing. I went through what it does, but I'm pretty sure that w...
I'm working on a predictive text solution and have all the words being retrieved from a Trie based on input for a certain string of characters, i.e. "at" will give all words formed with "at" as a prefix. The problem that I have now, is that we are also supposed to return all other possibilities from pressing these 2 buttons, Button 2 and...
I have a set of items, for example: {1,1,1,2,2,3,3,3}, and a restricting set of sets, for example {{3},{1,2},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{2,3},{2,3}. I am looking for permutations of items, but the first element must be 3, and the second must be 1 or 2, etc.
One such permutation that fits is:
{3,1,1,1,2,2,3}
Is there an algorithm ...
Hi,
I would like to get all combination of a number without any repetation.
Like 0.1.2, 0.2.1, 1.2.0, 1.0.2, 2.0.1, 2.1.0.
I tried to find an easy scheme but couldn't find so I drawed a graph/tree for it and this screams to use recursion.
But I would like to do it without, if this is possible.
So could anyone please help me how to do th...
For my program, I am trying to assist the user, and reduce his or her work load.
There are four input numbers. There is also an indeterminate amount of numbers they can be applied too.
For example, they four input numbers could be {4,7,3,2} and the numbers they can be applied to are {4,9,23}
The result should be: 4 (input) was applied...
R= repeats allowed -> 2
A= alphabet (1-10)
S= space = 4;
So we want example:
[1][1][4][5]
[1][7][4][5]
[5][1][4][5]
But need a fancy math formula to calculate this and all combinations ?
...
Hi everyone, I'm not sure how to ask my question in a succinct way, so I'll start with examples and expand from there. I am working with VBA, but I think this problem is non language specific and would only require a bright mind that can provide a pseudo code framework. Thanks in advance for the help!
Example:
I have 3 Character Arrays ...
In Python I have a list of n lists, each with a variable number of elements. How can I create a single list containing all the possible permutations:
For example
[ [ a, b, c], [d], [e, f] ]
I want
[ [a, d, e] , [a, d, f], [b, d, e], [b, d, f], [c, d, e], [c, d, f] ]
Note I don't know n in advance. I thought itertools.product wou...
..or do I have to give
P.nk <- factorial(n) / factorial(n-k)
or
P.nk <- choose(n,k) * factorial(k)
Thank you.
...
Hello,
I'm implementing the Verhoeff algorithm for a check digit scheme, but there seems to be some disagreement in web sources as to which permutation cycle should form the basis of the permutation table.
Wikipedia uses: (36)(01589427)
while apparently, Numerical Recipies uses a different cycle and this book uses: (0)(14)(23)(56789),...