[Jprogramming] Interesting Quora Problem:

2023-09-10 Thread 'Skip Cave' via Programming
Quora Question: Can you arrange the digits 1-9 to make a nine-digit number such that the first digit is divisible by one, the first two digits are divisible by two, the first three divisible by three and so on? My solution: ea=.&.> at=.>10#.ea(a=.362880 9$1 to 9){.ea{n=.>:perm 9 {:"1 at#~*./"1[0

Re: [Jprogramming] Interesting Quora Problem:

2023-09-10 Thread Raul Miller
I guess to simplify it, I would filter the possibilities at each step. first digit divisible by 1: N1=: 1+i.9 Second digit divisible by 2: N2=: ;(10*N1)+each (<2*1+i.4)-.each N Third digit divisible by 3: digits=: 10&#.inv N3=: (#~ 0=3|]);(10*N2)+each (<1+i.9) (-. digits) each N2 An

Re: [Jprogramming] Interesting Quora Problem:

2023-09-10 Thread Ben Gorte
If we do a bit of work by ourselves? Consider that the 5 has to be in fifth position (starting from 1), and that there must be even digits (four of them) on the even positions. The other four odd digits go to the remaining odd positions. Then there are only 576 possibilities left. odds =: (i.24) A

Re: [Jprogramming] Interesting Quora Problem:

2023-09-10 Thread 'Skip Cave' via Programming
Wow! Raul & Ben both provided solutions to my Quora problem that were radically different from my original solution, and radically different from each other. Both solutions reduced the execution time & space by several orders of magnitude, when compared with my original solution. Also, both used di