Because its relative to the sorted permutation (with repetitions) list of the 
argument.  A. does this as well.


A. 1 0
1
A. 0 2 1 
1




----- Original Message -----
From: Raul Miller <[email protected]>
To: Programming forum <[email protected]>
Sent: Thursday, May 5, 2016 7:25 PM
Subject: Re: [Jprogramming] permutation and combination numbers (with repeat)

I am not understanding, still. So let's try a different example:

Why are these equal?

   permN 0 0 1 0
1
   permN 0 1 0 1
1
   permN 1 0 1 1
1

Thanks,

-- 
Raul

On Thu, May 5, 2016 at 6:20 PM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
> Its relative to the sorted order of the input
>
> rp1 =: (] (] <@; $:^:(1<#)@del1~)"1 0 ~.@])
> untreep =: (({.,"0 1 $:^:(1<L.)@}.)&>)
> rperm6 =: (a: ;"1@(]#~ -.@e."1) ,&.:(<"1)@:untreep@:rp1)
>
> rperm6 0 0 1
> 0 0 1
> 0 1 0
> 1 0 0
>
>
> rperm6 0 1 1
> 0 1 1
> 1 0 1
> 1 1 0
>
>
>
> in both cases, the 0 index is the sorted order
>
>  permN 1 0 1
> 1
>  permN 1 0 0
> 2
>
> the index in their respective permutation lists.
>
> ----- Original Message -----
> From: Raul Miller <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Thursday, May 5, 2016 6:13 PM
> Subject: Re: [Jprogramming] permutation and combination numbers (with repeat)
>
> Why are these two results equal?
>
>    permN 0 0 1
> 0
>    permN 0 1 1
> 0
>
> Thanks,
>
> --
> Raul
>
>
> On Thu, May 5, 2016 at 5:58 PM, 'Pascal Jasmin' via Programming
> <[email protected]> wrote:
>> Some routines to calculate permutation and combination numbers, similar to 
>> A. (but allows permutations with repeat)
>>
>> del1 =: i.~ ({. , >:@[ }. ]) ]
>>
>> combN =: (0:`((<:@[ - {.@]) $: >:@{.@] -~ }.@])@.(0 < #@]) + 0:`(<:@#@] 
>> +/@:! <:@[ - i.@{.@])@.(0 < {.@]) )
>>
>> combNF =: 3 : 'a =. 1 { 0 {:: y label_. (i.a) + +/\ 1 {:: ([ (] ;~ [ -  1 ,~ 
>> _2 >:@{ ]) }:@] , {:@] ([ ({.@] ,(- {:)) ] (] , {~) 1 i:~ >:) (0 , ] 
>> (+/\)@:! ( a i.@:-~ [) -~ [)/@:<:@[ )&>/^: (<:a) y'@:;
>>
>> permC =: # %&(x:@:(*/))&:! #/.~
>>
>> permN1 =: ((0:`( (] - <./)@:({.@] del1 [)  $: (] - <./)@:}.@] )@.(1 < #@])) 
>> + (permC % #)@] * [ i.  {.@] ) f.
>>
>> permN =: /:~ permN1 ]
>>
>>   100x  combN   15 25 35 45 55 65 85
>> 11284989655
>>
>>   100 7 combNF  11284989655x
>> 15 25 35 45 55 65 85
>>
>>   permN 1 0 0 2 1 3 3 1
>> 434
>>
>> haven't done the reverse to permN yet, but these routines combined can be 
>> used to compress any list into 2 numbers (with a key).  You can google for 
>> combinatorial number base, and there is A., but not sure A. has been done 
>> for permutations with repeats.  Which produces smaller numbers than A. does 
>> (due to fewer underlying permutations).
>> ----------------------------------------------------------------------
>> 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

Reply via email to