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

Reply via email to