Yes, much better!
cf my suggestion a few days ago, and another constructive one using
tap and comb, q_tap_comb :
... time & space for Skip's original problem:
ts'10 #.(,/@:(],"1 0 -."1)^:2 ,.)>:i.9'NB. AG
0.000120949 40448
ts'10#.(#~(-:~.)"1) >: 9#.inv i. 9^3' NB. MD
0.000774292 84608
ts'q_tap_comb 3' NB. constructive, eg RM
0.00130777 39424
... generating required numbers in [12345, 98765]:
ts'10 #.(,/@:(],"1 0 -."1)^:4 ,.)>:i.9'
0.00548052 2.23386e6
ts'10#.(#~(-:~.)"1) >: 9#.inv i. 9^5'
0.066979 5.91731e6
ts'q_tap_comb 5'
0.0397513 2.11584e6
where
q_tap_comb =: tap @[ ,@(10 #."1 {&.:|:) >:@comb&9 f.
ie
q_tap_comb
(i.@! A. i.)@[ ,@(10 #."1 {&.:|:) >:@(4 : 0)&9
k=. i.>:d=.y-x
z=. (d$<i.0 0),<i.1 0
for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
; z
)
Thanks,
Mike
On 14/08/2017 18:16, Arie Groeneveld wrote:
My version of variations (without repetitions) :
10 #. (,/@:(],"1 0 -."1)^:2 ,.)1+i.9
More general:
(3) 4 :'y,/@:(],"1 0 -."1)^:(x-1) ,.y' 'abcd'
Op 12-08-17 om 11:16 schreef Skip Cave:
How can I use J to generate all the possible 3-digit integers that
can be
constructed using the digits 1-9 (no zeros), with no repeated digits in
each integer? The sequence starts with 123 (smallest) and goes to 987
(largest). Here's the first few integers in the sequence:
123 124 125 126 127 128 129 132 134 135 136 137 138 139 142 143 145
146 147
148 149 152 153 154 156 157 158 159 162......
Skip
Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm