[Jprogramming] challenge: optimizing permutations with repeat count
'Pascal Jasmin' via Programming
programming at jsoftware.com
Tue May 10 06:12:34 UTC 2016
Cool, but not quite the same. A permutation (in the sense I'm looking for) is constrained by a frequency count for each digit: Anagrams with repetition.
----- Original Message -----
From: Raul Miller <rauldmiller at gmail.com>
To: Programming forum <programming at jsoftware.com>
Sent: Tuesday, May 10, 2016 12:11 AM
Subject: Re: [Jprogramming] challenge: optimizing permutations with repeat count
Here's another approach for permutations with repetitions in J.
If we characterize a permutation with repetitions as belonging to a
sequence with a specific length a, and a maximum value b, and having
an index value y, we can a verb for the argument pattern (a,b) Ap y
like this:
Ap=: #/@[ #: ]
Example use:
10 60 Ap ?5#60^10x
34 56 50 9 15 28 34 11 40 43
32 9 50 41 37 25 41 18 36 47
30 27 17 58 19 40 41 2 31 25
23 18 33 58 24 20 32 38 38 0
29 16 32 9 59 46 36 15 10 40
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list