I was a bit eager on the send button with that last message.

Here is the previous approach, removing some superfluous stuff:

         , ". ,"1/^:3~ ,. '0126'
     0 1 2 6 10 11 12 16 20 21 22 26 60 61 62 66 100 101 102 106 110 111 ...

And here is essentially the same approach, but treating digits as actual 
numbers:

         ({~ /:) , 10&#.@,"0/~^:3~ 0 1 2 6
     0 1 2 6 10 11 12 16 20 21 22 26 60 61 62 66 100 101 102 106 110 111 ...

In either case, we are just taking the Cartesian product S^n X S, i.e. the 
,"0/~ part. This then reduces the problem to finding a function from said 
product down to the integers. I the first case, ". reads our strings of digits 
into numbers, while in the second case 10&#. effectively converts our list of 
digits into their base-10 integers.

Feel free to ask if anything is unclear! I'm just beginning with J myself, too, 
so there might be some way better approach that I missed.

On Mon, Oct 21, 2019 at 10:38:10AM +0900, 'B. Wilson' via Programming wrote:
> What about something like this?
> 
>         , ". (,/@:,"1/)^:3~ ,.'0126'
>     0 1 2 6 10 11 12 16 20 21 22 26 60 61 62 66 100 101 102 106 110 111 ...
> 
> If S is the set of our digits, then the above essentially is just the 
> Cartesian product S^4.
> 
> On Sun, Oct 20, 2019 at 06:08:48PM -0500, Skip Cave wrote:
> > Is there a less-verbose way to list all the integers (one-digit, two-digit,
> > three-digit, four-digit) can be formed by using the characters 0, 1, 2, and
> > 6 once? I used multiple takes:
> > 
> > *#b=.~.>10#.ea({1{."1 a),({2{."1 a),({3{."1 a),{a=.(perm 4){0 1 2 6*
> > 
> > *49*
> > 
> > *b*
> > 
> > *0 1 2 6 10 12 16 20 21 26 60 61 62 102 106 120 126 160 162 201 206 210 216
> > 260 261 601 602 610 612 620 621 1026 1062 1206 1260 1602 1620 2016 2061
> > 2106 2160 2601 2610 6012 6021 6102 6120 6201 6210*
> > 
> > 
> > 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to