hfstcnw=: ([:(# >:@i...@#) 2 , [: ; (0 <@; [: (<@{."0 _)~ >:@i.@>:)
(}:,>:@{:)@;@:{~&.>^:((<@])`(<@2:)) ])

   2-:/\(HCF 18);(hc10kE 18);hfstcnw 19
1 1

   ('HCF';'hc10kE';'hfstcnw') dspl rnkng scores 'HCF 18';'hc10kE
18';'hfstcnw 19'
+-------+----+-----+----+----+
|verb   |rank|et*sz|time|size|
+-------+----+-----+----+----+
|HCF    | 2  |6.40 |6.40|1.00|
+-------+----+-----+----+----+
|hc10kE | 1  |4.60 |3.68|1.25|
+-------+----+-----+----+----+
|hfstcnw| 0  |1.00 |1.00|1.00|
+-------+----+-----+----+----+


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Dan Bron
> Verzonden: zaterdag 13 maart 2010 22:38
> Aan: 'Programming forum'
> Onderwerp: Re: [Jprogramming] Fast(er) Hofstadter-Conway 10K $ sequence
> generation
> 
> Aai wrote:
> >  e.g. is it possible to avoid 'some' boxing.
> 
> I responded:
> >  Oh!  Sure.
> 
> The final form of the solution I posted to RC is:
> 
>          hc10kE     =:  1 1 , exp...@tail
>            expand   =:  2+I.@;
>            tail     =:  copies&.>^:(<@>:`(<@,@2:))
>              copies =:  >: |.@(#!.1 |.)~ 1 j. #;.1 #^:_1 ::1:~ ]~:{.
> 
> I added it as an "alternative solution", noting that while it is slightly
> more complex, it is exponentially faster.  Should I post the "true
> recursive" ($:) formulation as well?
> 
> -Dan
> 
> PS: I find it appealing that "copies" is a showcase for all the features
> of
> #  : tally, copy in its full generality (i.e. with complex arguments), and
> expand, with fit even.  The verb is also a good way to understand how
> expand
> differs from complex copy, and when you'd choose one over the other.
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to