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

Reply via email to