[Jprogramming] All unique permutations of a logical vector
Louis de Forcrand
olius at bluewin.ch
Wed Jun 1 13:28:33 UTC 2016
Thanks! Those were exactly what I was looking for.
Louis
> On 29 May 2016, at 23:12, Louis de Forcrand <olius at bluewin.ch> wrote:
>
> Is there a faster (and relatively concise) way of generating
> (~.@:A.~ i.@!@#) b
> where b is a logical vector (of 0s and 1s)?
> There are obviously (+/ ! #) b vectors in the result, but I can't
> see any relation in their anagram indices:
>
> I.@(-:"1/~ ~.)@(A. ~i.@!@#) 1 1 1 0 0
> 0 1 6 7 24 25 30 31 48 49 54 55
> 2 4 8 10 26 28 32 34 50 52 56 58
> 3 5 9 11 27 29 33 35 51 53 57 59
> 12 14 18 20 36 38 42 44 60 62 66 68
> 13 15 19 21 37 39 43 45 61 63 67 69
> 16 17 22 23 40 41 46 47 64 65 70 71
> 72 74 78 80 84 86 96 98 102 104 108 110
> 73 75 79 81 85 87 97 99 103 105 109 111
> 76 77 82 83 88 89 100 101 106 107 112 113
> 90 91 92 93 94 95 114 115 116 117 118 119
>
> The (< I , J )&{ of this table corresponds to the Jth occurence
> of the Ith unique permutation of the vector in its table of all
> possible permutations.
>
> Thanks,
> Louis
>
More information about the Programming
mailing list