Efficiently create derangement of a vector in R

I'm looking into a way of efficiently creating a derangement (and conversely specific permutations) of a vector in R. As far as I've seen, there's no base function that does that and also there's not much about it here on SO. An obvious start is sam...
more »

2017-08-02 13:08 (1) Answers

Print all the permutation of vector

Let's design a clock. This clock has a format of (hour: miniutes). Lets use bit to represent it. For example, 10: 15 is represented as 1010:1111. Question: given n as total number of bit that is 1, print all the possible clock time. (eg, in th...
more »

2017-07-31 03:07 (1) Answers

Haskell permutations matching criteria

How would one do the following in Haskell: Return all permutations of a list where one element comes before the another element (cannot assume that elements of the list can be ordered)? My solution was to do: sLeftOf l r lss = [ ls ...
more »

2017-07-22 23:07 (0) Answers

Positional equality in haskell list

If I have two lists, I want to define a positional equality (in a particular sense) between elements. For example if: k = [[3,1,2,4],[1,4,2,3],[1,3,4,2]] s = [["a","b","c","d"],["d","a","c","b"],["c","b","a","d"],["d","b","c","a"]] and I want to b...
more »

2017-07-21 02:07 (2) Answers

Finding even permutations using Haskell

I tried to figure out how to find the even permutations out of the set {permutations [1..n]}. I have asked this question before on a different forum, and got an answer that worked namely the code was: Import Data.List -- number of inversions in a p...
more »

2017-07-07 20:07 (1) Answers

Pandas: Pairwise concatenation of column vectors

I'm working with a frame like df = pd.DataFrame({ 'G1':[1.00,0.69,0.23,0.22,0.62], 'G2':[0.03,0.41,0.74,0.35,0.62], 'G3':[0.05,0.40,0.15,0.32,0.19], 'G4':[0.30,0.20,0.51,0.70,0.67], 'G5':[0.40,0.36,0.88,0.10,0.19] }) and I want to manipulate it so...
more »

2017-03-07 04:03 (2) Answers

Provably correct permutation in less than O(n^2)

Written in Haskell, here is the data type that proves that one list is a permutation of another: data Belongs (x :: k) (ys :: [k]) (zs :: [k]) where BelongsHere :: Belongs x xs (x ': xs) BelongsThere :: Belongs x xs xys -> Belongs x (y ': xs)...
more »

2017-03-05 00:03 (0) Answers

Algorithm to create subgroups of people

we are looking for an algorithm that could help us creating subgroups of people. I'll explain it better with an example: We have a group of 5 students, let's call them A, B, C, D, E. Given a number (call it n) smaller than the number of students (&l...
more »

2017-02-21 07:02 (1) Answers

C Multiple arrays permutations algorithm

I'm trying to write a program that generates permutations upon a list of words stored into several arrays. For example, my program asks for 2 groups of words like this : words #1: abc def ghi words #2: 123 456 What i'm trying to have is this outp...
more »

2017-01-13 11:01 (1) Answers