Yeah, it is for PE - ive done the other pandigital problems in C, but i wanted to try this one in J. My biggest problem seems to be trying to flatten the pandigitals. E.g.
9 8 7 6 5 4 3 2 1 I need to turn into 987654321. Is it possible to do that or do I need to do 1+2*10+3*100+...+9*100000000? ___________________________ David Vaughan On 8 Jul 2011, at 12:38, Ric Sherlock <[email protected]> wrote: > Project Euler? > > To get the permutations in reverse order you could reverse the string > or reverse the list of permutation indicies. i.e. > 0 1 2 3 A. 'cba' > 3 2 1 0 A. 'abc' > > In J you are better off testing the whole array of permutations rather > than looping through them, so > (1&p: # ]) i. 50 > or > (#~ 1&p:) i. 50 > 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 > > On Fri, Jul 8, 2011 at 10:53 PM, David Vaughan > <[email protected]> wrote: >> I'm trying to find the highest 1-9 pandigital prime, so I need to get the >> permutations in reverse order if possible. Also, how can I apply my >> primeTest script to the results? >> >> primeTest =: 3 : 'if. #@:q:y do. y end. ' >> This is what I have so far. The rank of y and of the list of permutations >> don't match up, and it feels like my 'if.' approach isnt great. >> >> Can anyone offer any advice as to how achieve this? >> >> Thanks. >> >> ___________________________ >> >> David Vaughan >> >> On 8 Jul 2011, at 11:29, Ric Sherlock <[email protected]> wrote: >> >>> (i.@!@# A. ]) 'abcd' >>> or >>> (A.~ i.@!@#) 'abcd' >>> >>> see also: >>> http://rosettacode.org/wiki/Find_the_missing_permutation#J >>> >>> On Fri, Jul 8, 2011 at 9:44 PM, David Vaughan >>> <[email protected]> wrote: >>>> >>>> How would you go about getting all the permutations of a string in J? >>>> ___________________________ >>>> >>>> David Vaughan >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
