Oops, I thought that looked funny..

no duplicates, but I had to use extended precision to see them.

   x:+/"1(10#,:10^i.-9)*((i.10) A. ]) i.9
12345678 12345687 12345768 12345786 12345867 12345876 12346578
12346587 12346758 12346785

That said, as Dan Bron pointed out, these are all evenly divisible by 9:

   9%~x:+/"1(10#,:10^i.-9)*((i.10) A. ]) i.9
1371742 1371743 1371752 1371754 1371763 1371764 1371842 1371843 1371862 1371865

-- 
Raul

On Fri, Jul 8, 2011 at 10:16 AM, Raul Miller <[email protected]> wrote:
> If you look at the first 10 values from +/"1 map*pan I think you will
> see duplicates:
>   +/"1 (10#,:i.-9)*((i.10) A. ]) i.9
> 84 85 85 87 87 88 85 86 87 90
>
> Is that what you really want?
>
> --
> Raul
>
> On Fri, Jul 8, 2011 at 10:08 AM, David Vaughan
> <[email protected]> wrote:
>> I have made a list called map:
>>   map=:362880 9 $ \:~10^i.9
>> And pan represents all the permutations of 1-9.
>> So what is wrong with this:
>>   (#~ 1&p:)+/"1 map*pan
>> ?
>>
>>
>> ___________________________
>>
>> David Vaughan
>>
>> On 8 Jul 2011, at 14:13, Roger Hui <[email protected]> wrote:
>>
>>> As Dan Bron indicated, if you are looking for pandigital
>>> primes it's best to avoid generating all permutations.
>>> Many of the permutations (e.g. ones where the last digit
>>> is even) are not prime; generating them only to reject them
>>> represents a large wasted effort.
>>>
>>>
>>>
>>> ----- Original Message -----
>>> From: David Vaughan <[email protected]>
>>> Date: Friday, July 8, 2011 6:03
>>> Subject: Re: [Jprogramming] Checking permutations
>>> To: Programming forum <[email protected]>
>>>
>>>> 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?
>>>
>>> ----------------------------------------------------------------------
>>> 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

Reply via email to