combinatorics

stacking and layering boxes in excel [closed]

安稳与你 提交于 2019-12-11 20:18:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I am layering, stacking my options in excel. I have asked the question in a similar way, however I now want to put some more detail into it. If I have n number of boxes to stack, the possible options to stack them is 2^n-1. Let me give an example of 3 boxes and we give them the names A, B, C and D. The way they

Generating all unique orders of looping series of characters (all circular permutations)

笑着哭i 提交于 2019-12-11 18:23:39
问题 I have a string that is made out of Xs and Ys . For the sake of the question let's say this string is constructed of Four-Xs and Two-Ys: XXYYYY How can I generate all of the possible unique strings that are made out of Four-Xs and Two-Ys given that the string is not considered unique if by looping (/rotating/shifting) its characters around it produces a string that was already found? For instance: XXYYYY is considered similar to YXXYYY and YYYXXY (cardinal numbers added clarify) 123456 612345

Efficiently generating “subtraction chains”

我怕爱的太早我们不能终老 提交于 2019-12-11 12:27:07
问题 I posted another question earlier if you want some context. It appears that I was on the wrong path with that approach. Addition chains can be used to minimize the number of multiplications needed to exponentiate a number. For example, a 7 requires four multiplications. Two to compute a 2 =a×a and a 4 =a 2 ×a 2 , and another two to compute a 7 =a 4 ×a 2 ×a. Similarly, I'm trying to generate all of the possible "subtraction chains" for a set of numbers. For example, given the set of numbers {1

What's the most efficient algorithm for generating all k-subsetsof an n-set?

别说谁变了你拦得住时间么 提交于 2019-12-11 12:14:46
问题 We are given a set of n elements and we'd like to generate all k -subsets this set. For example, if S={1,2,3} and k=2 , then the answer would be {1,2}, {1,3}, {2,3} (order not important). There are {n choose k} k -subsets of an n -set (by definition :-), which is O(n^k) (although this is not tight). Obviously any algorithm for the problem will have to run in time Omega({n choose k}) . What is the currently fastest known algorithm for this problem? Can the lower bound of {n choose k} actually

How to generate cross product of sets in specific order

岁酱吖の 提交于 2019-12-11 11:13:35
问题 Given some sets (or lists) of numbers, I would like to iterate through the cross product of these sets in the order determined by the sum of the returned numbers. For example, if the given sets are { 1,2,3 }, { 2,4 }, { 5 }, then I would like to retrieve the cross-products in the order <3,4,5>, <2,4,5>, <3,2,5> or <1,4,5>, <2,2,5>, <1,2,5> I can't compute all the cross-products first and then sort them, because there are way too many. Is there any clever way to achieve this with an iterator?

Find unique compositions of k-distinct-element subsets for a set of n elements

依然范特西╮ 提交于 2019-12-11 10:19:52
问题 This is an algorithmic problem. If I miss any existing function in Python that helps, please give a shout. Given a set s of n elements, we can use itertools.combinations() function in Python to find all the unique k-element subsets . Let's call the set containing all these subsets S . Notice that each such subset has k distinct elements. The problem is 2-step. First, given these k-distinct-element subsets, I want to compose (some of) them such that (a composition is simply a superset of some

Permutation for numbers in C

不问归期 提交于 2019-12-11 08:41:19
问题 I'm trying to write a C function to list all permutations of a set of numbers, in groups of five, including repeat numbers: 15-11-49-43-5 2-30-34-6-11 So it's easy enough to write a function to grab all permutations of a number set and throw them out, but mapped to a certain group size, i'm somewhat stuck.. 回答1: void visit(int *Value, int N, int k) { static level = -1; level = level+1; Value[k] = level; if (level == N) print(Value, N); else for (int i = 0; i < N; i++) if (Value[i] == 0) visit

Verify Combinatorial CNF SAT Encodings?

大城市里の小女人 提交于 2019-12-11 08:14:16
问题 I am trying to solve a combinatorial problem by using a SAT Solver. This involves the following steps: Encode the problem as set of boolean expressions. Translate a conjunction of the expressions into CNF/DIMACS (using home grown tools, bc2cnf, bool2cnf or Limboole) Solve the CNF (using SAT Solvers like Cryptominisat, Plingeling, Clasp or Z3) Translate the solution (assuming a "SAT" result) back into the problem domain This works in my case for small samples. But for more challenging ones,

Knapsack with items to consider constraint

心已入冬 提交于 2019-12-11 07:07:15
问题 I have items I1, I2, I3, I4 with weights W1...W4 and Values V1...V4. I want to maximize values with minimum weights. This is a traditional Knapsack. However there is small constraint some items cannot go together. So lets say I2 and I3 cannot go together. Can anyone provide a dynamic programming solution or any other solution for the same. 回答1: With this constraint, the problem becomes strongly (as opposed to discrete knapsack, which is only weakly NP-hard) NP-hard. Suppose all your items

Generating permutations which are not mirrors of each other

纵饮孤独 提交于 2019-12-11 05:04:29
问题 I want to generate permutations of n numbers, where there is no two permutations which are reversions of each other (the first one read from the last character to the first is the same as the second one). For instance, n = 3, I want to generate: 1 2 3 //but not 3 2 1 1 3 2 //but not 2 3 1 2 1 3 //but not 3 1 2 I do not care which one of the two will be generated. The algorith should be applicable for large n (>20). Is there any such algorithm or a way to check if the generated permutations is