permutation

Iterate permutation per row per item

☆樱花仙子☆ 提交于 2019-12-25 17:46:28
问题 I would like to manipulate data to do network analysis using ggnet. The dataset is in csv form and looks like this: offers {9425, 5801, 18451, 17958, 16023, 7166} {20003, 17737, 4031, 5554} {19764, 5553, 5554} What I would like to break the array, and iterate to permute all the items each row as a pair of 2. So the ultimate output should look like: print list(itertools.permutations([1,2,3,4], 2)) per row to create: (9425, 5801) (9425, 18451) (9425, 17958) (9425, 16023) (9425, 7166) (5801,

Combinations of 4-digit numbers whose individual digits sum to 5

泪湿孤枕 提交于 2019-12-25 14:07:28
问题 I'm working on a scorecard at work which has columns representing 4 possible outcomes, for example: Successful, unsuccessful, Exceptional, Other Each staff member is assessed 5 times in the month against those ratings. So 1 person might have 3 successful , 2 exceptional , 0 unsuccessful , 0 other . So the max instances of each outcome is 5 but the total sum of instances can't be more than 5. I could try to type out all the combinations (and get them wrong) - is there any function/formula/VBA

Combinations of 4-digit numbers whose individual digits sum to 5

落花浮王杯 提交于 2019-12-25 14:07:26
问题 I'm working on a scorecard at work which has columns representing 4 possible outcomes, for example: Successful, unsuccessful, Exceptional, Other Each staff member is assessed 5 times in the month against those ratings. So 1 person might have 3 successful , 2 exceptional , 0 unsuccessful , 0 other . So the max instances of each outcome is 5 but the total sum of instances can't be more than 5. I could try to type out all the combinations (and get them wrong) - is there any function/formula/VBA

Permutation of N lists

只谈情不闲聊 提交于 2019-12-25 13:19:12
问题 i need all permutation from N lists, i dont know N until the program start, here is my SSCCE (i have implemented algorithm which was adviced to me, but it has some bugs). First , create Place class: public class Place { public List<Integer> tokens ; //constructor public Place() { this.tokens = new ArrayList<Integer>(); } } And then testing class: public class TestyParmutace { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application

Permutation of N lists

こ雲淡風輕ζ 提交于 2019-12-25 13:18:50
问题 i need all permutation from N lists, i dont know N until the program start, here is my SSCCE (i have implemented algorithm which was adviced to me, but it has some bugs). First , create Place class: public class Place { public List<Integer> tokens ; //constructor public Place() { this.tokens = new ArrayList<Integer>(); } } And then testing class: public class TestyParmutace { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application

Excel permutations without repetition from values in multiple columns

落爺英雄遲暮 提交于 2019-12-25 12:10:10
问题 What I have in Excel document: A B Abc 12:34 Def 56:78 Ghi 90:12 Jkl 34:56 ... What I want to achieve with those values: C D E F Abc 12:34 Def 56:78 Abc 12:34 Ghi 90:12 Abc 12:34 Jkl 34:56 Def 56:78 Ghi 90:12 Def 56:78 Jkl 34:56 Ghi 90:12 Jkl 34:56 ... Explanation: Columns A and B can contain any combination of text and numbers (if that is important at all), this example only displays the most common structure. It should create combinations only for rows "on the way down", i. e. "Abc...Def...

Faster string permutation

≡放荡痞女 提交于 2019-12-25 04:59:11
问题 I have permutation methods public void permute(String str) { permute(str.toCharArray(), 0, str.length() - 1); } private void permute(char[] str, int low, int high) { if (low == high) { writeIntoSet(new String(str, 0, length)); } else { for (int i = low; i <= high; i++) { char[] x = charArrayWithSwappedChars(str, low, i); permute(x, low + 1, high); } } } private char[] charArrayWithSwappedChars(char[] str, int a, int b) { char[] array = str.clone(); char c = array[a]; array[a] = array[b];

Listing all permutations of a string/integer

笑着哭i 提交于 2019-12-25 03:35:32
问题 A common task in programming interviews (not from my experience of interviews though) is to take a string or an integer and list every possible permutation. Is there an example of how this is done and the logic behind solving such a problem? I've seen a few code snippets but they weren't well commented/explained and thus hard to follow. 回答1: First of all: it smells like recursion of course! Since you also wanted to know the principle, I did my best to explain it human language. I think

All possible permutations for large n

有些话、适合烂在心里 提交于 2019-12-25 03:03:40
问题 I want to find all possible permutations for large n using R. At the moment I am using permutations(n,n) from gtools package, but for n>10 it is almost impossible; I get memory crashes due to the large number of permutations (n!). I do not want to sample as I need to find the exact distribution for a particular statistic. Is there any way I can do this faster or that I can break it down into small blocks? 回答1: Your goal is very likely to be impractical (how large is "large n"??? even if you

Get all possible string sequences where each element comes from different set in R

天涯浪子 提交于 2019-12-25 02:57:37
问题 Assume I have 4 vectors of character elements: s1 <- c("o", "ó") s2 <- c("c", "ć") s3 <- c("o", "ó") s4 <- c("z", "ź", "ż") I want to build 4-element vectors that are all possible combinations of elements from s1 , s2 , s3 , s4 in a way that in one of a result vectors 1-st, -2nd, 3-rd and 4-th element comes from s1 , s2 , s3 , s4 , respectively. For example, I would like to get the following result vectors: [1] "o", "c", "o", "z" [1] "ó", "c", "o", "z" [1] "o", "ć", "o", "z" ... [ My general