f1=.[: +/ ] !~/ [: i. # f1 i.4 4 6 4 1 f1 4?4 4 6 4 1 Replacing power with binomial coefficient also works, and the numbers involved are smaller.
f i.8 8 28 140 784 4676 29008 184820 1.2003e6 f1 i.8 8 28 56 70 56 28 8 1 Den 10:26 torsdag den 10. juli 2014 skrev Bo Jacoby <[email protected]>: > > >The power sums of rearrangements of a list of numbers match. > > > f=.[:+/]^/[:i.# > (f 5?5)-:f i.5 >1 > > > > > >Den 10:07 torsdag den 10. juli 2014 skrev Jon Hough <[email protected]>: > > >> >> >>The following two 4x4 arrays are rearrangements of each other's rows. >> >> >>3 2 1 0 >> >> >> >>1 0 3 2 >> >> >> >>2 3 0 1 >> >> >> >>0 0 0 0 >> >> >> >> >> >> >> >> >>2 3 0 1 >> >> >> >>3 2 1 0 >> >> >> >>1 0 3 2 >> >> >> >>0 0 0 0 >> >> >>I would like to know a way to acknowledge two arrays as being rearrangements >>of each other. Eventually my goal is to compare long lists of such arrays and >>nub out duplicates - duplicates being rearrangements. >> >> >>The only way I can think to do this is to cycle through all permutations of >>the row of one of the arrays and test for equality with the other array, using A. . Of course, there are 24 permutations to test for 4x4 arrays, but obviously for bigger arrays things get worse. >> >> >>Is there a faster way to check two arrays are (ignoring row permutations) >>equivalent? >> >> >> >> >> >>---------------------------------------------------------------------- >>For information about J forums see http://www.jsoftware.com/forums.htm >> >> >> > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
