combinations

No of numbers less than a given number with no repeating digits

荒凉一梦 提交于 2019-12-26 06:10:21
问题 How can we find the number of numbers less than a given number with no repeating digits in it? For example the number of such numbers less than 100 is 90. (11, 22, 33,44, 55,66,77,88,99 have repeating digits so are excluded). Similarly for less than 1000, digits like 101, 110, 122, 202 etc have to be excluded. 回答1: Here is a way to make it quicker. Notice that there is a correlation between the number of digits in the max number and the solution (number of numbers which I will call NON ) 100

How to choose all possible combinations?

≯℡__Kan透↙ 提交于 2019-12-25 19:40:21
问题 Let's assume that we have the list of loans user has like below: loan1 loan2 loan3 ... loan10 And we have the function which can accept from 2 to 10 loans: function(loans) . For ex., the following is possible: function(loan1, loan2) function(loan1, loan3) function(loan1, loan4) function(loan1, loan2, loan3) function(loan1, loan2, loan4) function(loan1, loan2, loan3, loan4, loan5, loan6, loan7, loan8, loan9, loan10) How to write the code to pass all possible combinations to that function? 回答1:

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

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...

Unique combinations of all variables

妖精的绣舞 提交于 2019-12-25 11:58:12
问题 I have attempted to use the following code to come up with a table of unique combinations of a bunch of variables. V1=as.vector(CRmarch30[1]) V2=as.vector(CRmarch30[2]) V3=as.vector(CRmarch30[3]) V4=as.vector(CRmarch30[4]) V5=as.vector(CRmarch30[5]) V6=as.vector(CRmarch30[6]) V7=as.vector(CRmarch30[7]) As you may have already guessed, CRmarch30 is a dataframe with 7 columns. I converted each column into a vector. Then, i used the following code to create all unique combination of the 7

No of ways of placing k distinguishable items into n distinguishable boxes

杀马特。学长 韩版系。学妹 提交于 2019-12-25 07:12:45
问题 Distinguishable objects into distinguishable boxes It is very similar to this question posted. I'm trying to get python code for this question. Note although it is similar there is a key difference. i.e. A bucket can be empty, while the other buckets contain all the items. Even this case will be considered as a separate case. for example: Consider I have 3 items A,B,C and 3 buckets B1, B2, B3 The table below will show the expected result: B1 B2 B3 (A,B,C) () () () (A,B,C) () () () (A,B,C) (A)

Depth-first combination algorithm

隐身守侯 提交于 2019-12-25 05:18:23
问题 Let's say I have the following array of arrays: A = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'], ['i'], ['j', 'k', 'l'] ] I want to find all possible combinations of the elements of each array with the elements of the other arrays (i.e. 'adgij' is one possibility but not 'abcde'). I can brute force it and just loop everything like this (javascript): var A = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'], ['i'], ['j', 'k', 'l'] ], combinations, newCombinations = []; A.forEach(function(a,

python string replacement, all possible combinations #2

主宰稳场 提交于 2019-12-25 04:46:06
问题 I have sentences like the following: ((wouldyou)) give me something ((please)) and a bunch of keywords, stored in arrays / lists: keywords["wouldyou"] = ["can you", "would you", "please"] keywords["please"] = ["please", "ASAP"] I want to replace every occurrence of variables in parentheses with a suitable set of strings stored in an array and get every possible combination back. The amount of variables and keywords is undefined. James helped me with the following code: def filler(word, from

Generate all combinations, of all lengths, in R, from a vector [duplicate]

醉酒当歌 提交于 2019-12-25 04:16:05
问题 This question already has answers here : Unordered combinations in R (2 answers) Closed 3 years ago . Suppose I have the vector ["a","b","c"] , then I'd like to create a list of vectors of all the unique combinations, of all sizes (order does not matter): ["a"] ["b"] ["c"] ["a","b"] ["a","c"] ["b","c"] ["a","b","c"] How can I do this in R? 回答1: We can try with combn do.call("c", lapply(seq_along(v1), function(i) combn(v1, i, FUN = list))) data v1 <- letters[1:3] 来源: https://stackoverflow.com