[Jprogramming] Permutations
Dan Bron
j at bron.us
Fri Sep 23 06:19:23 HKT 2011
If speed is a big concern, then I imagine (haven't tested) that ": would
be faster than 10&#.^:_1 .
I used to have an intellectual distaste for choosing ": to get the digits of
the number (because "I'm dealing with numbers, not strings", right?) but
someone recently pointed out that to even say "digit" is to treat the number
as string (a symbolic representation of a quantity, not an abstract
quantity), so that gave me ease :)
-Dan
PS: Can you tell I'm trying to make my name bigger on Ken's tag cloud?
-----Original Message-----
From: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] On Behalf Of Henry Rich
Sent: Thursday, September 22, 2011 5:54 PM
To: Programming forum
Subject: Re: [Jprogramming] Permutations
The digits, you mean?
-:&:(/:~)&:(10&#.^:_1)"0
would be one way. Is 35 a permutation of 503?
Henry Rich
On 9/22/2011 5:41 PM, David Vaughan wrote:
> Hi, what is the best (fastest) way to check whether a number is a
permutation of another number?
> I've tried listing all permutations of one number and checking whether the
other number is in the list of permutations. This seems pretty slow, so I
was hoping for a faster method.
>
> Thanks.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list