Re: [Jprogramming] restricting permutations

2020-05-26 Thread 'Jon' via Programming
Observation (a) is a direct result of the properties of dihedral groups. All permutations can be generated by a single rotation and a single reflection. https://groupprops.subwiki.org/wiki/Dihedral_group If instead of i. 4, the original question contained i. 5, with similar adjacency

Re: [Jprogramming] restricting permutations

2020-05-26 Thread Roger Hui
The timing is because A. (currently) doesn't "know" that it's being invoked with i.!n . FYI, the Jwiki essay *Permutation Index *describes how A. does its thing. A. is particularly amusing on large arguments. (_1+!30x) A. i.30 29 28

Re: [Jprogramming] restricting permutations

2020-05-26 Thread 'Mike Day' via Programming
Yes, I tend to agree. Brian’s enquiry limits the choice to 8 out of the 24 perms, so filter on all is eminently simplest. It was, however, quite interesting to (a) find that (any) one solution can spawn the other 7 by rotations and reverses, and (b) find a constructive method, albeit rather

Re: [Jprogramming] restricting permutations

2020-05-26 Thread David Lambert
For small sets I'd start with the permutations, then select those I like. This shows two anti-selectors, sum of pairs equal 3, and in r2 the bad guys are directly spelled. permutations=: A.~ ! Filter=: "1(#~`)(`:6) restrictions=: 1 (-.@e.) 3 = 2&(+/\) NB. 1 where none of the length 2

Re: [Jprogramming] restricting permutations

2020-05-26 Thread Jan-Pieter Jacobs
Makes perfect sense, noting that because dyadic A. has left-rank 0, it is called !10 times… On Tue, May 26, 2020, 09:06 Raul Miller wrote: > There's an opportunity here for improving idioms like (A.~ !) > > But, A. is already a lot faster than perm in some other contexts: > >!10 > 3.6288e6

Re: [Jprogramming] restricting permutations

2020-05-26 Thread Raul Miller
There's an opportunity here for improving idioms like (A.~ !) But, A. is already a lot faster than perm in some other contexts: !10 3.6288e6 3e6 A. i.10 8 2 4 1 7 0 3 5 6 9 3e6 { perm 10 8 2 4 1 7 0 3 5 6 9 timespacex '3e6 A. i.10' 4e_6 1856 timespacex '3e6 { perm 10' 0.198427

Re: [Jprogramming] restricting permutations

2020-05-26 Thread Jan-Pieter Jacobs
Yes, I just figured it out the same definition. However, I was very surprised to see perm massively outperforms tap: timespacex 'a=: perm 10' 0.3946 3.18771e8 timespacex 'b=: (A.&:i.~ !) 10' 2.74118 5.62038e8 a-:b 1 JVERSION Engine: j901/j32/android Release-e:

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Devon McCormick
Late to the party: rmEntry=: ([: -. [: +./ [: ; (1 2;2 1;0 3;3 0) E.&.> <)"1 (] #~ rmEntry) (i.!4) A. i.4 0 1 3 2 0 2 3 1 1 0 2 3 1 3 2 0 2 0 1 3 2 3 1 0 3 1 0 2 3 2 0 1 On Mon, May 25, 2020 at 5:35 PM Skip Cave wrote: > The perm in the addon library is dyadic: > > 2 perm 4 > > 0 1 > > 1

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Skip Cave
The perm in the addon library is dyadic: 2 perm 4 0 1 1 0 0 2 2 0 0 3 3 0 1 2 2 1 1 3 3 1 2 3 3 2 Skip Cave Cave Consulting LLC On Mon, May 25, 2020 at 4:23 PM Skip Cave wrote: > Actually you can just say load 'stats' and get perm, comb, and much more. > > When I do a Google

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Skip Cave
Actually you can just say load 'stats' and get perm, comb, and much more. When I do a Google search on: site:jsoftware.com perm I get: https://code.jsoftware.com/wiki/Addons/stats/base/sampledesign Skip Cave Cave Consulting LLC On Mon, May 25, 2020 at 4:05 PM Ric Sherlock wrote: > Skip,

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Ric Sherlock
Skip, that seems like a very old version of the stats/base addon? According to GitHub the sampledesign script was renamed to combinatorial back in 2008. perm is currently available in ~addons/stats/base/combinatorial.ijs (stats/base/combinatorial) On Tue, May 26, 2020 at 8:45 AM Skip Cave wrote:

Re: [Jprogramming] restricting permutations

2020-05-25 Thread 'Mike Day' via Programming
If I can’t remember the idiom, I look for “tap.” My favourite form is tap =: A.~ ! (perm-: tap)3. NB. Same results. 1 Cheers, Mike Sent from my iPad > On 25 May 2020, at 21:44, Skip Cave wrote: > > perm > > 3 : 0 > > z=. i.1 0 > > for. i.y do. z=. ,/ (0 ,. 1 + z) {"2 1

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Skip Cave
Perm is in Addons/stats/base/sampledesign. perm 3 : 0 z=. i.1 0 for. i.y do. z=. ,/ (0 ,. 1 + z) {"2 1 \:"1 = i. 1 + {: $z end. : ,/ ({~ perm@#)"1 x comb y ) Skip Cave Cave Consulting LLC On Mon, May 25, 2020 at 3:23 PM Brian Schott wrote: > Skip, > I am having trouble finding perm.

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Brian Schott
Skip, I am having trouble finding perm. I tried using A. in its place, but did not succeed. But I think I see where you were going. Good idea. On Mon, May 25, 2020 at 2:54 PM Skip Cave wrote: > ssmb=:+./@E. > > l21=.-.1 1 ssmb"1+./"2]1 2=/"1 n=.perm 4 > > l30=.-.1 1 ssmb"1+./"2]0 3=/"1 n > >

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Skip Cave
ssmb=:+./@E. l21=.-.1 1 ssmb"1+./"2]1 2=/"1 n=.perm 4 l30=.-.1 1 ssmb"1+./"2]0 3=/"1 n n#~l30*.l21 0 1 3 2 0 2 3 1 1 0 2 3 1 3 2 0 2 0 1 3 2 3 1 0 3 1 0 2 3 2 0 1 Skip Cave Cave Consulting LLC On Mon, May 25, 2020 at 6:48 AM Brian Schott wrote: > I want all permutations of i. 4

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Brian Schott
[I thought I had sent this message after Mike's first, but apparently forgot to "Send"] Hauke, I could not figure out your approach. Mike, I think your solution is correct. I tested it with the following approach. First I went to NuVoc and looked up A. to find the following line of code. n=:

Re: [Jprogramming] restricting permutations

2020-05-25 Thread 'Mike Day' via Programming
... and here’s an explicit function to generate the minimal solution, and indeed the minimal solutions for each starting value: rp =: 3 : 0 NB. generate minimal restricted perm where adjacent pairs' sums .ne. 3 cur =. p =. 4 | y NB. suitable seed l =. cur -.~ i. 4 while. #l do. p =. p,

Re: [Jprogramming] restricting permutations

2020-05-25 Thread 'Jon Hough' via Programming
The constraints (0,3) must never be adjacent, and (1,2) must never be adjacent means you are essentially looking for the symmetries of a square. If you consider a square with 4 points, labeled 0,1,2,3 like this: 0 -- 1 | | | | | | | | | | 3 -- 2 the symmetries of

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Hauke Rehr
I sometimes don’t get the order of thoght and speech right. Sorry for shouting 16 prior to thinking well about it. For each first number, the third is fixed, so there are only two possible ways (permute the other 2). In total, that’s 8. Am 25.05.20 um 14:15 schrieb 'Mike Day' via Programming: I

Re: [Jprogramming] restricting permutations

2020-05-25 Thread 'Mike Day' via Programming
I think there are 8 solutions. Given one, minimal, solution, 0 1 3 2, how about this? ((,|."1)@:(|."0 1~i.@#))'0132' 0132 1320 3201 2013 2310 0231 1023 3102 Any use? Mike Sent from my iPad > On 25 May 2020, at 12:47, Brian Schott wrote: > > I want all permutations of i. 4 for which 0

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Hauke Rehr
Sorry, 0 2 1 3 is obviously wrong, I meant to say 0 3 2 1 Am 25.05.20 um 14:01 schrieb Hauke Rehr: is this a more general task, or do you only ever have exactly four items to arrange that way? an easier way of doing what you did would be take any solution, the 0 2 1 3&{ of it, the |. of both,

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Brian Schott
Only 4 items. On Mon, May 25, 2020 at 8:01 AM Hauke Rehr wrote: > is this a more general task, or do you only ever > have exactly four items to arrange that way? > > -- For information about J forums see

Re: [Jprogramming] restricting permutations

2020-05-25 Thread Hauke Rehr
is this a more general task, or do you only ever have exactly four items to arrange that way? an easier way of doing what you did would be take any solution, the 0 2 1 3&{ of it, the |. of both, and apply (i.4) |."1 to all four. That sould get you all possible 16 solutions maybe someone else