My solution, not as terse as the others: f=: +/@:(0&=)@:([ | ".@{./"0 _)
search=: 3 : 0 r=. 0 c=. 1 while. c < (!9) do. c=.c+1 a=. '123456789' {~ c A. i. 9 r=.(>: i.9) f a if. r -: 9 do. break. end. end. a ) search '' 381654729 Thanks, Jon On Monday, September 11, 2023 at 03:02:42 AM GMT+9, 'Skip Cave' via Programming <programm...@jsoftware.com> wrote: 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=a|"1 at 381654729 The answer is 381654729. Check: ]m=.>10#.ea(;/1 to 9){.ea{sep 381654729 3 38 381 3816 38165 381654 3816547 38165472 381654729 (1 to 9)| m 0 0 0 0 0 0 0 0 0 There is only one answer. Is there a way to simplify or minimize the big repetitive array 'a' to make the two J code lines more memory efficient & succinct? 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