I haven't seen that idiom before, thanks. I am wondering whether it finds duplicates in linear time... like #/. does, still, good thing to learn.
--- Original Message --- From: "Tikkanz" <[email protected]> Sent: July 21, 2015 12:59 PM To: "Programming JForum" <[email protected]> Subject: Re: [Jprogramming] Substring sequences of a string (i.~ ~: i:~) will find duplicates so how about: ~.@(#~ i.~ ~: i:~)@(10 ]\ ]) s AAAAACCCCC CCCCCAAAAA On Tue, Jul 21, 2015 at 3:51 PM, Jon Hough <[email protected]> wrote: > This is a problem from leetcode.com (similar to Project Euler) > https://leetcode.com/problems/repeated-dna-sequences/ > The problem is to find all 10 letter repeated subsequences from a DNA > string (made of C,G,A,T characters). > My solution: > func =: (I.@:(1&<)@:>@:(1&{)@:(~. ,: <"0@:(#/.~)) { ])@:(<"1@:(10&(]\))) > e.g. s =: 'AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT' NB. see the link for this > definition > func s > ┌──────────┬──────────┐ > > │AAAAACCCCC│CCCCCAAAAA│ > > └──────────┴──────────┘ > > > > It is not very pretty. Can anyone improve on it? > > ---------------------------------------------------------------------- > 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
