B. Wilson,

I like your last approach:

, 10#.,"1/^: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 112 116
120 121 122 126 160 161 162 166 200 201 202 206 210 211 212 216 220 221 222
226 260 261 262 266 600 601 602 606 610 611 612 616 620 621 622 626 660 661
662 666 1000 1001 1002 1006 1010 1011 1012 1016 1020 1021 1022 1026 1060
1061 1062 1066 1100 1101 1102 1106 1110 1111 1112 1116 1120 1121 1122 1126
1160 1161 1162 1166 1200 1201 1202 1206 1210 1211 1212 1216 1220 1221 1222
1226 1260 1261 1262 1266 1600 1601 1602 1606 1610 1611 1612 1616 1620 1621
1622 1626 1660 1661 1662 1666 2000 2001 2002 2006 2010 2011 2012 2016 2020
2021 2022 2026 2060 2061 2062 2066 2100 2101 2102 2106 2110 2111 2112 2116
2120 2121 2122 2126 2160 2161 2162 2166 2200 2201 2202 2206 2210 2211 2212
2216 2220 2221 2222 2226 2260 2261 2262 2266 2600 2601 2602 2606 2610 2611
2612 2616 2620 2621 2622 2626 2660 2661 2662 2666 6000 6001 6002 6006 6010
6011 6012 6016 6020 6021 6022 6026 6060 6061 6062 6066 6100 6101 6102 6106
6110 6111 6112 6116 6120 6121 6122 6126 6160 6161 6162 6166 6200 6201 6202
6206 6210 6211 6212 6216 6220 6221 6222 6226 6260 6261 6262 6266 6600 6601
6602 6606 6610 6611 6612 6616 6620 6621 6622 6626 6660 6661 6662 6666

However, the requirement states "using the characters 0, 1, 2, and 6 once"
so duplicate digits not allowed..

~.>10#.ea({1{."1 a),({2{."1 a),({3{."1 a),{a=.(perm 4){0 1 2 6

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


On Sun, Oct 20, 2019 at 11:23 PM 'B. Wilson' via Programming <
[email protected]> wrote:

> Over lunch, I just realized that my second implementation using integer
> digits could be expressed a lot more directly:
>
>         , 10#. ,"1/^: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 ...
>
> Which nicely mirrors the implementation using strings.
>
>
> On Mon, Oct 21, 2019 at 11:32:54AM +0900, 'B. Wilson' via Programming
> wrote:
> > 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
> ----------------------------------------------------------------------
> 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