Jimmy,

Can you give me the link to the topic on the J programming forum where Arie
Groeneveld and others discuss verbs that perform all permutations of x size
taken from y items.

You stated that Arie came up with this solution:
vari =: 4 :'y,/@:(],"1 0 -."1)^:(x-1) ,.y'

I would like to see others' solutions to that same problem.

Skip


On Tue, Nov 7, 2017 at 6:11 PM, Jimmy Gauvin <[email protected]> wrote:

> This problem was solved earlier this year.
>
> I retained this solution from  Arie Groeneveld but there were many others.
> It works with numbers and characters.
>
>    vari =: 4 :'y,/@:(],"1 0 -."1)^:(x-1) ,.y'
>
> 2 vari 'abc'
>
> ab
>
> ac
>
> ba
>
> bc
>
> ca
>
> cb
>
>
>    #4 vari 1 3 4 6 8 9
>
> 360
>
>
>
>
> On Tue, Nov 7, 2017 at 7:07 PM, 'Mike Day' via Programming <
> [email protected]> wrote:
>
> > That number is 360,   ie
> >      (!4) * 4!6
> > as reported on that Quora example’s link.
> >
> > The comb verbs return the number of combinations,  not of permutations.
> >
> > Cheers,
> >
> > Mike
> >
> >
> > Please reply to [email protected].
> > Sent from my iPad
> >
> > > On 7 Nov 2017, at 22:26, 'Skip Cave' via Programming <
> > [email protected]> wrote:
> > >
> > > How many four digit numbers can be formed from the number 1,3,4,6,8 and
> > 9 if
> > > repetition of digits is not allowed?
> > > <https://www.quora.com/How-many-four-digit-numbers-can-
> > be-formed-from-the-number-1-3-4-6-8-and-9-if-repetition-of-
> > digits-is-not-allowed>
> > >
> > > Using Erling's CombE:
> > >
> > > b =. 4 CombE 6
> > >
> > >   a =. 1 3 4 6 8 9
> > >
> > >   #c = b#a
> > >
> > > 15  NB. so the answer is 15.
> > >
> > > NB. Convert to decimal
> > >
> > >    10 10 10 10#. c
> > >
> > > 1346 1348 1349 1368 1369 1389 1468 1469 1489 1689 3468 3469 3489 3689
> > 4689
> > >
> > >
> > > Wait a minute!
> > >
> > > What happened to 1364, 1384, 1396, 1436, 1438, 1439, and lots more?
> > >
> > > I was hoping CombE would give all combinations of y items taken x at a
> > time
> > >
> > >
> > > Skip
> > >
> > >
> > >
> > >
> > >>
> > > ----------------------------------------------------------------------
> > > 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

Reply via email to