Thanks for the several nice solutions to the Quora problem. On Quora, most of the solutions to this type of problem are like Mike Day's approach, where they use logic to finesse the answer.
I prefer the "brute force" approach, listing and eliminating candidates in bulk. J's array-handling primitives makes this style of solution fairly straightforward, and I don't have to spend time analyzing and thinking about multiples, factors, etc. Raul's solution is perfect: brutish & short - and elegant. The conversion of binary to decimal was a cool way to solve the "by 60 and not by 24" problem that I was struggling with. Then using I. to avoid the copy (#-binary select) operation that I would have used, gave me a new option for solving these types of problems. Skip Skip Cave Cave Consulting LLC On Tue, Dec 19, 2017 at 1:25 PM, Raul Miller <[email protected]> wrote: > Here's one approach: > > I.1=#.|:0=24 60 |/i.1001 > 60 180 300 420 540 660 780 900 > > Thanks, > > -- > Raul > > > On Tue, Dec 19, 2017 at 1:52 PM, 'Skip Cave' via Programming > <[email protected]> wrote: > > How many numbers from 1 to 1000 are divisible by 60 but not by 24? > > > > Here's my somewhat inelegant explicit solution: > > > > #e=.c#~d=.-.0=24|/c=.a#~b=.0=60|/a=.1+i.1000 > > > > 8 > > > > > > NB. What are the numbers? > > > > e > > > > 60 180 300 420 540 660 780 900 > > > > > > How would I construct a more compact tacit solution? > > > > > > 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 > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
