An approach that uses characters:
D=:'023456789'
A3=:(,D~:/D)# >,{D;D
B3=: ".(0{"1 A),.' ' ,. 1{"1 A3
MASK=: (#~ 8=+/"1) #:i.2^10
C3=:,/MASK ([ + -.@[ #inv ])"1/ B3
ALL2-:C3
1
Compare this with Raul's strategy and deleting double letters.
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Thursday, June 21, 2012 11:27 PM
To: 'Programming forum'
Subject: Re: [Jprogramming] "Limited" Permutations
Also:
(8!10)*9*8
3240
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Thursday, June 21, 2012 11:17 PM
To: 'Programming forum'
Subject: Re: [Jprogramming] "Limited" Permutations
Don't you have to remove the occurrences of two digits that are alike?
$ALL
3645 10
OTHER2=:((0{"1 OTHER)~:1{"1 OTHER)#OTHER
ALL2=:,/MASK ([ + -.@[ #inv ])"1/ OTHER2
$ALL2
3240 10
That is how I interpreted the original problem.
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Thursday, June 21, 2012 11:02 AM
To: Programming forum
Subject: Re: [Jprogramming] "Limited" Permutations
Here's one approach:
OTHER=: >,{;~1 -.~i.10
MASK=: (#~ 8=+/"1) #:i.2^10
,/MASK ([ + -.@[ #inv ])"1/ OTHER
--
Raul
On Thu, Jun 21, 2012 at 10:51 AM, David Vaughan <[email protected]>
wrote:
> Hi, I'm trying to generate all permutations of length 10 with eight 1s and
two other digits (not 1s).
> For example,
> 1 1 1 1 3 1 4 1 1 1
> 5 1 1 1 1 9 1 1 1 1
> ...
>
> Could anyone point me in the right direction?
>
> Many 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
----------------------------------------------------------------------
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