Always room for improvement
((# 2 1$~#)^:(39) 2 2) -: ;(,L:0/, (# # $ 2 1 (-.|.[){:)L:0@{:)^:(39)
2; 2
1
#(# 2 1$~#)^:(39) 2 2
21717701
ts' ;(,L:0/, (# # $ 2 1 (-.|.[){:)L:0@{:)^:(39) 2; 2'
0.53642622 4.6976922e8
ts'(# 2 1$~#)^:(39) 2 2'
0.99308559 8.0530931e8
R.E. Boss
> -----Original Message-----
> From: [email protected] [mailto:programming-
> [email protected]] On Behalf Of Mike Day
> Sent: donderdag 15 januari 2015 16:39
> To: [email protected]
> Subject: Re: [Jprogramming] Kolakosky sequence
>
> Plagiarising Raul and Aai's brilliant insights (and presumably RE Boss's),
> as I got nowhere near those efficiencies, it seems you can get a slight
> improvement in time and space using a boolean array until termination:
>
> 1 ts'#(>:# ((1 0$~#)))^:(40) 1 '
>
> 1.62761 4.69765e8
>
>
> 1 ts'(# 2 1$~#)^:(40) 2 ' NB. slower laptop here!
>
> 1.84354 8.05309e8
>
>
> Mike
>
> On 15/01/2015 14:07, Aai wrote:
> > Probably identical to what you have:
> >
> > (# 2 1$~#)^:(40) 2
> >
> >
> >
> > R.E. Boss schreef op 15-01-15 om 13:03:
> >> K=. 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 1 2 1
> >> 2 2 1
> >> 2 2 1 1 2 1 2 2 1 2 1 1 2 1 1 2 2 1 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 1 2
> >> 1 2 2
> >> 1 2 1 1 2 2 1 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 2
> >> 2 1 1
> >> is the start of a sequence where each i-th number gives the length of
> >> the
> >> i-th substring of equal numbers.
> >> Or in J
> >> (}:#;.(2)~ 2~:/\]) K
> >> 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 1 2 1 2 2
> >> 1 2 2
> >> 1 1 2 1 2 2 1 2 1 1 2 1 1 2 2 1 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 1 2 1 2
> >>
> >> (Partial) equality from
> >> ((]-: ({.~ #)) }:#;.(2)~ 2~:/\]) K
> >> 1
> >>
> >> I do have a way to generate them (not by hand), but what are other
> ways?
> >> Elegant and lean svp.
> >>
> >> The first 21717701 items I generated in
> >> ts 'genREB 2'
> >> 0.9922127 8.0530995e8
> >>
> >>
> >> R.E. Boss
> >>
> >>
> >> ----------------------------------------------------------------------
> >> For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2014.0.4800 / Virus Database: 4257/8933 - Release Date: 01/15/15
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm