ts 'ssd3 0' NB. Jacobs 0.0049295 4718752 $ ssd3 0 33219
ts '1e5+I.+./(3#"1":i.10 1) +./@E."1/ ":1e5+i.9e5 1' NB. Miller 0.3565249 58725056 $ 1e5+I.+./(3#"1":i.10 1) +./@E."1/ ":1e5+i.9e5 1 33219 ts 'sn #~ 1 e."(1) 3 #@~.\"1] sn' NB. Boss 0.5836545 34605056 $ sn #~ 1 e."(1) 3 #@~.\"1] sn 33219 6 ts '$(#~ triple"1) sn' NB. Fondren 0.7807501 3147712 $ (#~ triple"1) sn 33219 6 Jacobs' solution is by far the fastest, almost 200 times the solution of Fondren, which is the thinnest. No need for D 😉 Nice to see the different approaches. R.E. Boss -----Original Message----- From: Programming <[email protected]> On Behalf Of 'Mike Day' via Programming Sent: zondag 4 juli 2021 10:50 To: [email protected] Subject: Re: [Jprogramming] Cut ... prepend ..., thanks to iPad spell correction! M Sent from my iPad > On 4 Jul 2021, at 09:24, Mike Day <[email protected]> wrote: > > That’s what I was thinking too, or even take all 3-digit numbers & insert, > pretend, append triples... > again, it’s better if you’re happy with quads etc. > > Cheers, > > Mike > > Sent from my iPad > >> On 4 Jul 2021, at 08:50, Jan-Pieter Jacobs <[email protected]> >> wrote: >> >> Not using cut here, but I took a generative approach: >> >> ssd3=: 10#. [:~.[:,/(1 1 1 3 |."0 1~ i. 4) #"1/ (4#10)#: >> 1000+i.@9000"_ >> >> It basically starts from all 4 digit numbers, repeats each digit in >> turn, then takes them all together and nubs it. >> I guess it's fine if your definition considers 3 or more repetitions >> as being fine. >> >> I didn't double check all, but a quick random check seems to confirm >> the >> outcome: >> >> ({~ 20 ?@$ #) ssd3 0 >> 333975 956664 529777 947772 886661 811175 666289 622212 858777 637773 >> 843999 488844 506662 267779 577728 111463 418444 861119 916333 722214 >> >> and it seems to run reasonably fast even on my phone: >> >> 30 timex 'ssd3 0' >> 0.020757 >> >> Best regards, >> >> Jan-Pieter >> >>> On Sun, Jul 4, 2021, 05:53 Raul Miller <[email protected]> wrote: >>> >>> Oops, I should have replace i.9 1 with i.10 1 >>> >>> $1e5+I.+./(3#"1":i.10 1) +./@E."1/ ":1e5+i.9e5 1 >>> 33219 >>> >>> Sorry about that... >>> >>> -- >>> Raul >>> >>>> On Sat, Jul 3, 2021 at 11:51 PM Raul Miller <[email protected]> wrote: >>>> >>>> You did not include a definition for triple here, and I have no way >>>> of reproducing your result. >>>> >>>> This is a bit slower to execute (0.37 seconds on my laptop), but >>>> faster to implement: >>>> >>>> $1e5+I.+./(3#"1":i.9 1) +./@E."1/ ":1e5+i.9e5 1 >>>> 29816 >>>> (12345+i.10){1e5+I.+./(3#"1":i.9 1) +./@E."1/ ":1e5+i.9e5 1 >>>> 444993 444994 444995 444996 444997 444998 444999 445000 445111 >>>> 445222 >>>> >>>> -- >>>> Raul >>>> >>>> On Sat, Jul 3, 2021 at 7:59 PM Julian Fondren >>>> <[email protected]> >>> wrote: >>>>> >>>>> On Saturday, July 3rd, 2021 at 6:50 PM, Julian Fondren < >>> [email protected]> wrote: >>>>>> That takes about 80x as long as the attached method using the FFI >>>>>> and a quick library in D. >>>>> >>>>> That attachment got stripped? Well, it's nothing special. >>>>> >>>>> extern(C) void triples(int* xs, int len) @nogc { >>>>> foreach (i; 0 .. len) >>>>> xs[i] = triple(xs[i]); >>>>> } >>>>> >>>>> triplesd =: './libtriple.so triples n *i i'&cd >>>>> triples =: [: triplesd (; #) >>>>> triples 123334 122344 121212 111222 112122 555432 >>>>> +-+-----------+-+ >>>>> |0|1 0 0 1 0 1|6| >>>>> +-+-----------+-+ >>>>> $(#~ triple"1) sn >>>>> 33219 6 >>>>> $(#~ 1 {:: triples) n >>>>> 33219 >>>>> 30 timex '$(#~ triple"1) sn' >>>>> 0.869076 >>>>> 30 timex '$(#~ 1 {:: triples) n' >>>>> 0.0100672 >>>>> >>>>> ------------------------------------------------------------------ >>>>> ---- 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
