permutation

How to perform a check on a permutation “on-the-fly” without storing the result in R

不羁的心 提交于 2020-02-05 06:18:29
问题 Assume we have the following permutations of the letters, "a", "b", and "c": library(combinat) do.call(rbind, permn(letters[1:3])) # [,1] [,2] [,3] # [1,] "a" "b" "c" # [2,] "a" "c" "b" # [3,] "c" "a" "b" # [4,] "c" "b" "a" # [5,] "b" "c" "a" # [6,] "b" "a" "c" Is it possible to perform some function on a given permutation "on-the-fly" (i.e., a particular row) without storing the result? That is, if the row == "a" "c" "b" or row == "b" "c" "a" , do not store the result. The desired result in

Excel Combination Generator

心已入冬 提交于 2020-02-05 02:03:44
问题 i have a code that generates a permutation based on the inputs of 8 columns and concatenates the columns together. it works great so far but i came up with a problem. it works when more than 2 rows are filled. so if theres only one entry in row 10 for any of the columns from A-H it crashes. the rows are filled with A,B,C across all 8 columns, if column 8 only had A then it crashes I've also tried Set col1 = Range(Range("A10"), Range("A" & Rows.Count).End(xlUp)) instead of Set col1 = Range(

How to get nth permutation when repetition is allowed?

北城以北 提交于 2020-02-03 23:31:20
问题 Project Euler 24: What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? What if repetitions are allowed? like 1111111111 , 1223344457 etc. How can I get millionth permutation where repetitions are also included in counting. And please note that input would still be the same. No repetitions in input. I want to generate all possible passwords of length 10. And passwords can contain repeated characters so I want my function to work for that too. Here is

Makefile permutation

这一生的挚爱 提交于 2020-01-30 08:45:11
问题 Bash can produce permutations (cartesian product): $ echo {1,2}{a,b} 1a 1b 2a 2b I would like to do something similar with a makefile. Here is an example makefile: all: 1a 1b 2a 2b I would like something like this if possible: NOV = 1 2 OSC = a b all: $(NOV)$(OSC) However when I use an example like that it just creates "1 2a b" instead of combining them. Is this possible? 回答1: No need for any complex loops or borrowing from shell. It is much simpler than that. $(foreach p, $(NOV), $(addprefix

Makefile permutation

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-30 08:45:05
问题 Bash can produce permutations (cartesian product): $ echo {1,2}{a,b} 1a 1b 2a 2b I would like to do something similar with a makefile. Here is an example makefile: all: 1a 1b 2a 2b I would like something like this if possible: NOV = 1 2 OSC = a b all: $(NOV)$(OSC) However when I use an example like that it just creates "1 2a b" instead of combining them. Is this possible? 回答1: No need for any complex loops or borrowing from shell. It is much simpler than that. $(foreach p, $(NOV), $(addprefix

Generate all permutations in Java [duplicate]

一笑奈何 提交于 2020-01-29 06:35:46
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Generating all permutations of a given string I have an array of arbitrary length in Java, and I would like to generate all possible permutations of them. The easy way to do this for a fixed length would be a series of nested for loops, but because the array is of unknown length, that is not an option here. Is there a straightforward way to accomplish this in Java? 回答1: Use a recursive function, instead of loops

C# String permutation

蹲街弑〆低调 提交于 2020-01-28 02:20:59
问题 I have 5 strings, such as: "one", "two", "three", "four", and "five". I need to get all permutations of these strings. I've explored all internet resources, but all solutions are so bulky and it's hard for me to understand it and integrate it to my program. So, maybe you know any easy solution how to get permutations. 回答1: Permutations are very easy to do. /// <summary> /// Returns all permutations of the input <see cref="IEnumerable{T}"/>. /// </summary> /// <param name="source">The list of

C# String permutation

假如想象 提交于 2020-01-28 02:20:07
问题 I have 5 strings, such as: "one", "two", "three", "four", and "five". I need to get all permutations of these strings. I've explored all internet resources, but all solutions are so bulky and it's hard for me to understand it and integrate it to my program. So, maybe you know any easy solution how to get permutations. 回答1: Permutations are very easy to do. /// <summary> /// Returns all permutations of the input <see cref="IEnumerable{T}"/>. /// </summary> /// <param name="source">The list of

Next permutation in lexicographic order n k

孤街醉人 提交于 2020-01-25 10:11:48
问题 I'm want to write function that returns next permutation in lexicographic order n choose k. So far I found following algorithm class Permutation { public function swap(& $a, $first, $second) { $tmp = $a[$first]; $a[$first] = $a[$second]; $a[$second] = $tmp; } function nextPermutation(& $a, $n, $k) { do { $first = $n - 2; while ($first != -1 && $a[$first] >= $a[$first + 1]) $first--; if ($first == -1) return false; $second = $n - 1; while ($a[$first] >= $a[$second]) $second--; $this->swap($a,

Next permutation in lexicographic order n k

梦想与她 提交于 2020-01-25 10:10:11
问题 I'm want to write function that returns next permutation in lexicographic order n choose k. So far I found following algorithm class Permutation { public function swap(& $a, $first, $second) { $tmp = $a[$first]; $a[$first] = $a[$second]; $a[$second] = $tmp; } function nextPermutation(& $a, $n, $k) { do { $first = $n - 2; while ($first != -1 && $a[$first] >= $a[$first + 1]) $first--; if ($first == -1) return false; $second = $n - 1; while ($a[$first] >= $a[$second]) $second--; $this->swap($a,